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 tried it with the function extracted from this page:


I added the code to my functions.php, but I can't find any element with the class 'parent-menu-item', despite having several pages with sub-items in my WordPress installation.

What could I possibly be doing wrong here? Any other functions in my functions.php are working without problems.

share|improve this question
Can you show me the code and send me the site URL? – Vinod Dalvi Apr 15 '13 at 9:04
The site URL is uklose.ks1.klose-it.de/ssgbs. The code in my functions.php has been copy & pasted from the URL mentioned in my original post, I changed nothing. Thanks for your help. – Ulf Klose Apr 15 '13 at 9:45
You're aware that there are already parent and ancestor classes by default? current_page_ancestor and current_page_parent ? There are variants for menu ancestors where the item is a link or post rather than a page too, you don't need a custom class – Tom J Nowell Apr 15 '13 at 10:39
What I want to achieve is that in my main menu, if an element has child elements there should be a special icon near the element itself to show that there's a list of children to display. – Ulf Klose Apr 15 '13 at 13:26

Your Answer


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

Browse other questions tagged or ask your own question.