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 am using following code to get my menu.

My problem is Span is not getting added and I want to remove the first separator.

<div id="sub_nav">
<?php $menuParameters = array(
    'container'       => false,
    'echo'            => false,
    'items_wrap'      => '%3$s',
    'depth'           => 0,
    'before'           => '<span id="separator"> | </span>'
); ?>
<?php echo strip_tags(wp_nav_menu( $menuParameters ), '<a>' ); ?>

The output I got is:

<div id="sub_nav">
    | <a href=""> Fashion Insider</a>
    | <a href=""> Leasing</a>
share|improve this question
Are you putting that entire piece of PHP in a template file or in functions.php? Also, strip_tags is why you're not getting your span tags. Its only set to allow a or anchor tags. See answer below – AndyWarren Feb 28 '13 at 17:44

If all you're attempting to do is add a separator between links you'd be better off just scrapping what you have and do this:

Create a new menu in the WP backend. Add your pages/links and save the menu.

Then just use <?php wp_nav_menu( array('menu' => 'Name of Menu Here' )); ?> to display your menu. It will render an unordered list that you can then style using CSS

Use CSS to style the <li> tags that are rendered. Give each one a left or right border to achieve your separators. That will also not include an unnecessary span tag around each on to just ad a pipe separator.

share|improve this answer
This is the option I use all the time. Just as an FYI, it may be better to use border-left and :first-child since Internet Explorer 8 Doesn't Support :last-child – Howdy_McGee Aug 29 '13 at 14:21

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.