Is there a way of manually specifying which page is currently “active” when using wp_nav_menu()?

I have a “Products” page, and on that page I have links to various (dynamic) custom taxonomies. When I click on one of these taxonomies, I stay on the “Products” page but wp_nav_menu() loses reference to that fact that I’m still on the “Products” page. Is there a way I can fix this?

Thanks!

Jon

3 s
3

If you just want to add the current_page_item class to one menu item, you could hook up to the nav_menu_css_class filter, and add that class if needed. It is called when the menu is printed.

If you want access to the whole menu and add classes, hook in to the wp_get_nav_menu_items filter, where you get the whole $items array. You can edit the classes properties of individual items.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *