Answer the question
In order to leave comments, you need to log in
How to make dropdown menu items in WordPress?
There is a ready-made website layout, you need to make it a theme for WP. It has 4 menu items: "Home", "News", "Courses", "Contacts". The "Courses" item, when clicked with the mouse, opens 3 courses: "Course 1", "Course 2", "Course 3". I tried to set child menu elements in the admin panel via Appearance -> Menu, but then the layout breaks and is displayed incorrectly. The fact is that the layout is written in the Materialize framework, and the menu is written there as follows:
<ul>
<li><a href="#">Главная</a></li>
<li><a href="#">Новости</a></li>
<li><a class='dropdown-button' href='#' data-activates='dropdownThis'>Курсы</a></li> <!-- вот элемент с раскрывающимся списком -->
<ul id='dropdownThis' class='dropdown-content '>
<li><a href="#!">Курс 1</a></li>
<li><a href="#!">Курс 2</a></li>
<li><a href="#!">Курс 3</a></li>
</ul>
<li><a href="#">Контакты</a></li>
</ul>
Answer the question
In order to leave comments, you need to log in
As a result, I found a ready-made solution for embedding the bootstrap menu on the Internet and remade it for myself
https://github.com/twittem/wp-bootstrap-navwalker
wp has a Walker_Nav_Menu class. He is responsible for building the menu. You need to extend it with your class, in which you specify that if the element has children, then add the css class of the drop-down menu to it.
By default, the wordpress menu is generated in the same way, but with its own classes. You did the right thing by adding sub-items to the menu through the admin panel. You need to look at the css file and change something there. I won't say what exactly, because I don't see the site.
Wordpress has this feature. Look at the documentation for it. There are a lot of input parameters that you can use to change the menu output template. You need to add this function to the template where the menu is displayed (most likely the header.php file). Another option is not steamed, but simply insert the finished html menu code into the same file.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question