I have a menu set up like this:

Page 1
Page 2
    Page 2.1
    CPT Archive
    Page 2.2
Page 3

And when I navigate to the Archive, the Page 2 menu item does not have the "current-menu-ancestor" or "current-menu-item" classes.

Is this a bug or am I misunderstanding how WordPress menu classes should work?

  • I believe that's correct. There's no relation liking the Archive page and Page 2. The nesting done in appearances -> menu, does not create a relation.
    – gdaniel
    Jan 17 '17 at 18:49
  • Ah, I expected the two classes to be added depending on the structure of the menu, not the page hierarchy. Too bad! Guess I'll just use a page and a shortcode instead. Thanks.
    – The Maniac
    Jan 17 '17 at 18:53
  • You can also try using body classes. So your menu highlight would change according to the body class on the document.
    – gdaniel
    Jan 17 '17 at 19:40
  • You can also use the nav_menu_css_class filter to modify classes for specific menu items.
    – Milo
    Jan 18 '17 at 4:22

It seems this is being fixed in the next version of Wordpress. As a ticket with a patch is now labeled 4.8, check https://core.trac.wordpress.org/ticket/39800.

  • 1
    Just for the records, it was not patched in 4.8. The ticket milestone has been changed for future release
    – TheBird956
    Jun 15 '17 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.