WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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'm working on a custom dropline menu using wp_nav_menu.

Using wp_nav_menu( array( 'theme_location' => 'primary', 'after' => '|' ) );, I can put separators after every item. However, I'm only wanting them after the child items in the sub-menu.

Is there any way I can be more specific about which items have separators, such that only the non-parent items are separated?


share|improve this question
up vote 1 down vote accepted

Why not use a purely CSS-based solution, using the :after pseudo-element? e.g.

#nav li li a:after {
    content: '|';
share|improve this answer
I completely forgot about using the "content" attribute. That's totally what I was looking for, thanks! – aendrew Jul 22 '11 at 18:26

You can extend Walker class which wordpress uses for wp_nav_menu to style your menu in your way....

Here is an example...


share|improve this answer

For a similar project, I used a single line of jQuery to selectively add spacers:

jQuery('ul#menu-main-menu-1 li.menu-item-267, ul#menu-main-menu-1 li.menu-item-265').append(' | ');

Leaving question open in hopes that somebody has a more elegant solution than this...

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.