multi-level dropdown menus
Hello, I am building my website and I want a menu of products where the list of products is displayed and each product in turn contains another list of the products that are part of the main list.
That is, a menu with a submenu that contains internal submenus
Sorry for my bad English, all my language is Spanish, greetings from Panama.
Current configuration of the primary menu in my WordPress
This is an example of what you tried to achieve:
Hello, I have solved by searching for Google and I have come to this article
link
Unfortunately it was not with the direct configuration from the program and I had to go for additional codes.
In the footer of the page, put the following script:
$(document).ready(function(){
$(‘.dropdown-menu > li > .dropdown-menu’).parent().addClass(‘dropdown-submenu’).find(’ > .dropdown-item’).attr(‘href’, ‘javascript:;’).addClass(‘dropdown-toggle’);
$(‘.dropdown-submenu > a’).on(“click”, function(e) {
var dropdown = $(this).parent().find(’ > .show’);
$(‘.dropdown-submenu .dropdown-menu’).not(dropdown).removeClass(‘show’);
$(this).next(‘.dropdown-menu’).toggleClass(‘show’);
e.stopPropagation();
});
$(‘.dropdown’).on(“hidden.bs.dropdown”, function() {
$(‘.dropdown-menu.show’).removeClass(‘show’);
});
});
then in a code editor edit the header.php by default it places the program ‘depth’ => 2
<? php wp_nav_menu (array (‘theme_location’ => ‘primary’, ‘depth’ => 2,
change it ‘depth’ => 4
<? php wp_nav_menu (array (‘theme_location’ => ‘primary’, ‘depth’ => 4,
and well it was achieved that the menu works as I wanted:
If someone knows a better and more practical option, I thank you, greetings.