Make WordPress Core

Opened 5 years ago

Last modified 3 years ago

#47436 new defect (bug)

Menu depth doesn't affect menu-item-has-children

Reported by: mikeybinns's profile mikeybinns Owned by:
Milestone: Awaiting Review Priority: normal
Severity: trivial Version: 5.2.1
Component: Menus Keywords: needs-patch
Focuses: Cc:



When you add a depth of 1 to wp_nav_menu it removes all the sub menus, but it leaves menu-item-has-children class on the original menu li tags, which means it is styled like it has a dropdown.

Attachments (2)

47436.patch (725 bytes) - added by rishishah 5 years ago.
Fix with tests
47436.2.patch (684 bytes) - added by viralsampat 5 years ago.
Updated Patch.

Download all attachments as: .zip

Change History (5)

5 years ago

Fix with tests

#1 @rishishah
5 years ago

  • Keywords has-patch added; needs-patch removed

5 years ago

Updated Patch.

#2 @mikeybinns
5 years ago

  • Keywords needs-patch added; has-patch removed

These patches work for the first depth (the main line) but the class is also added to lower level submenus.


Depth = 1
<li class="no-class">
  <a>menu item</a>

Depth = 2
<li class="menu-item-has-children">
  <a>menu item</a>
  <ul class="sub-menu">
    <li class="menu-item-has-children">
      <a>2nd depth menu item with removed submenu</a>

I think this needs some kind of depth iterator, so the function knows the max depth and the current item depth.


#3 @sabernhardt
3 years ago

Related/duplicate: #28620

Note: See TracTickets for help on using tickets.