I was wondering if there's any way to discover which categories are "active" on a category archive page. This is for the purpose of menu highlighting.

To demonstrate, compare these:

(1) Parent category archive: http://building.mediumutm.ca/test-cat/ In the menu, the category is highlighted because it's active - cool. But so are both the dropdown menu links, its subcategories.

(2) Post in the parent category: http://building.mediumutm.ca/post-test-cat/ Working perfectly. Only the parent category is active and highlighted, not the dropdowns.

So it's really only (1) that's a problem, and I suspect it's not a CSS class issue because (2) works fine... So it that that archive page treats the subcategories as active? If so, can I disable that? Or what?


1 Answer 1


Alas, this is a CSS issue, caused by some difference in WP's classes applied. :)

First you are misinterpreting your "test" case 2:

  1. Dropdown isn't highlighted because (despite what post body says) it's not actually assigned the subcategory.
  2. The styling applied is from .current-menu-parent, since post is obviously not a term in taxonomy.

In your first case the class at work is .current-menu-item, since we are looking at the term in taxonomy. Next the CSS rules .current-menu-item a applies to all links inside of it and since dropdown HTML is inside top level item HTML it all gets styled as "current".

You should be limiting such rules to immediately nested links inside container — .current-menu-item > a (which is already done correctly for .current-menu-parent > a).

  • Brilliant, thanks! And now I learn about child vs. descendant. Commented Aug 21, 2014 at 16:46

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.