How to set the menu active state for a custom posttype and category, given a custom taxonomy term?

I have a custom taxonomy: region, a custom posttype: business, and use the categories taxonomy. My custom primary menu consists of the region terms.

When I select a region, the corresponding menu item is highlighted OK. The region page shows a listing of relevant categories. Now, when I select a category on this page the corresponding menu item is not highlighted. In turn, the category page shows a listing of businesses. Also, when I click on a business, the corresponding menu-item is not highlighted.

So, how to set the menu active state on a category page and on a business post, given a custom taxonomy term? I do have a session variable region available on these pages.

2 Answers 2


When you create a custom menu item for the custom post type archive you have to include the entire url and not just /your-custom-post-type-name. If you use the entire url the wordpress url rewrite function will check it against all the other menu items as well as against all your pages and so on. What you end up with in the menu parent is something like current-menu-ancestor current-menu-parent current_page_parent current_page_ancestor.

  • Thanks. That definitively is more flexible! However I noticed that not in all cases the current-menu-ancestor, current-menu-parent, current_page_parent and current_page_ancestor get set. This is e.g. the case when showing a (custom) post belong to a category listed as a child in a custom menu. Nevertheless, the solution you pointed out is workable in most cases.
    – Henk Jan
    Commented Apr 12, 2011 at 6:33

You probably can do this via CSS. As the body has classes lined up depending on the page that is displayed and the menu entries have classes and ids on their own, you can probably hardcode the highlight into custom CSS.

If the highlighting is done with markup instead of CSS then this is not possible. But I think that is not the case.

So inspect (e.g. with Firebug) the body tag on those pages and check for the ids of the menu items. Next to that you can check how the highlighting is done with Firebug.

The rest should be copy and paste.

  • Thanks for the answer. I think it will work for me - I will check it out tonight.
    – Henk Jan
    Commented Dec 17, 2010 at 14:45
  • Worked out allright. Thanks. (only drawback: this solution is not flexible - but hey, I am happy with your solution)
    – Henk Jan
    Commented Dec 17, 2010 at 21:49
  • @Henk: Yes, it's sort of hardcoded, but you could genererate the CSS based on the page. So it would become a bit more flexible.
    – hakre
    Commented Dec 17, 2010 at 23:58

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.