WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I believe this doesn't happen very often. I am working on a project in which a child page can show up under several different parent pages.

The page actually belongs to just one parent, but in the main navigation it needs to show up under two or more parents. Don't ask me why, people like to be redundant.

I am using wp_nav_menu to create the main navigation.

My structure is:

Parent A - child 1 - child 2

Parent B - child 1 - child 2 - child 3 (this child is the same as Parent A Child 2)

Parent C - child 1 - child 2 (this child is the same as Parent A Child 2 and Parent B Child 3) - child 3

I normally use the classes current-menu-ancestor current-menu-parent to highlight the navigation because they typically only show in one <li> , but because some children are listed several times under different parents, those classes are no longer unique to the page. So I ended up with two or more highlighted items. All other classes are also exactly the same in this case. There's not one unique class to select.

Has anyone run into a similar issue? I can only fix this by using javascript, comparing ID and then unhighlighting the wrong ones. But I was wondering if there's a wordpress solution (filters) or a css solution.

share|improve this question

A filter solution could be the nav_menu_css_class filter. A CSS solution could be to use the body_class to make more specific css rules.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.