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

alt text

and here is a printscreen of navbar created by wp_categories_list()

alt text


  • Is the current-menu-item or current-page-item class not what you're looking for? Commented Dec 23, 2010 at 13:35
  • You are seeking to highlight the top most parent element when the current page is direct descendent, correct? I'd like to know this answer to. OT: I wish WP did not add all those 'menu-item menu-item type-post_type' redundant classes!
    – Scott B
    Commented Dec 23, 2010 at 16:22

2 Answers 2


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.

  • That feeling when I find my own answer from two years ago, and its wrong. Ugh. The filter is actually named nav_menu_css_class. Commented Oct 19, 2012 at 20:51

You can style this classes,

"current-cat" "current-menu-item" "current-page-item"

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.