I've been using the native wp_nav_menu to output my navigational elements. I have also created a subpage that is nested under one of my menu, but when I hit that URL the default custom walker clearly doesn't activate the corresponding item in the menu.


Home, FAQs

MY question is how can I get the FAQs menu turning on if I'm on the archive URL?

Thanks Andrea

  • Does FAQs not have the class in the list-item current-page-ancestor to style? – Howdy_McGee Apr 28 '14 at 22:01
  • Where's the code for the default custom walker? – Brad Dalton Apr 28 '14 at 22:01
  • @BradDalton I have used the custom walker, hence anything customised from my side. – Andrea Moro Apr 28 '14 at 22:34
  • @Howdy_McGee to clean up a bit the mess the wp_nav_menu creates by adding dozens of classes, I removed some of them. I can possibly look on how to get the current-page-ancestor replaced in a similar fashion to activate it. Thanks for the hint. – Andrea Moro Apr 28 '14 at 22:36
  • @Howdy_McGee sorry to go back to this, but I looking at the current-page-ancestor class, I can't find any. Is there something else I can use? – Andrea Moro May 16 '14 at 17:15

As pointed out from @Howdy_McGee it should be possible to use the current-menu-anchestor css class.

However, using the standard menu walker in a CPT archive page taxonomically nested under a menu item I wasn't able to get the class out as expected.

The solution I adopted was to add a create a filter to inject the required class

add_filter( 'wp_nav_menu_objects', 'am_filter_menu_class' );
| improve this answer | |

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.