Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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>' ); ?>
</div>

The output I got is:

<div id="sub_nav">
    | <a href=""> Fashion Insider</a>
    | <a href=""> Leasing</a>
</div>
share|improve this question
1  
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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.