In my site i have a navbar which is created by using the new feature of wordpress 3 – “the menus “.In my site this navbar conatins both categories and pages.
When I’m in a single post / sub-page , the navbar doesn’t give the parent category /page the class of “current-menu-item” and therefore that item in the navbar is not highlighted.
I found this but it really doesn’t help me because the menu is not built on
category_ID like a regualr navbar created by wp_categories_list(), but on item_ID , which I don’t understand how is generated.
I would like to know either how the item_ID is generated, and/or how to highlight the right item in the navbar
Here is a printscreen of my navbar’s HTML
and here is a printscreen of navbar created by wp_categories_list()
thanks!!
The filter you need is nav_menu_css_classes. You should be able to test for *in_category* on single post and archive pages, and add the appropriate class there.
You can style this classes,
“current-cat”
“current-menu-item”
“current-page-item”