0

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.

E.g.

Home, FAQs
      >____Archive

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

Thanks Andrea

7
  • Does FAQs not have the class in the list-item current-page-ancestor to style?
    – Howdy_McGee
    Apr 28, 2014 at 22:01
  • Where's the code for the default custom walker? Apr 28, 2014 at 22:01
  • @BradDalton I have used the custom walker, hence anything customised from my side. Apr 28, 2014 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. Apr 28, 2014 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? May 16, 2014 at 17:15

1 Answer 1

0

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' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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