how can i Add multiple levels of submenus to a Bootstrap 5 navigation bar in my WordPress theme using bootstrap navwalker

391 Views Asked by At

I am a new wordpress developer and i want to now tow to create multie levels sub menu in wordpress by using bootstrap 5 nav walker class . i can make a simple menue with one level for sub menu but i want to add more thane one level to my menue .

1

There are 1 best solutions below

1
Serg On

  // dropdown multilevel
    window.jQuery('.dropdown-menu > li > .dropdown- 
   menu').parent().addClass('dropdown-submenu').find(' > .dropdown- 
   item').attr('href', 'javascript:;').addClass('dropdown-toggle');
   window.jQuery('.dropdown-submenu > a').on('click', function(e) {
    var dropdown = $(this).parent().find(' > .show');
    window.jQuery('.dropdown-submenu .dropdown- 
   menu').not(dropdown).removeClass('show');
    window.jQuery(this).next('.dropdown-menu').toggleClass('show');
    e.stopPropagation();
    });

    // hide all open menus if the parent closes
    window.jQuery('.dropdown').on('hidden.bs.dropdown', function() {
    window.jQuery('.dropdown-menu.show').removeClass('show');
    });
/* multilevel navigation */
    .dropdown-submenu { position: relative; }
    .dropdown-submenu .dropdown-menu { top: 0; left: 95%; margin-top: -1px; }