WordPress.org

Support

Support » How-To and Troubleshooting » Remove first seperator

Remove first seperator

  • Hi,
    I am using following code get my menu
    In this Span is not getting added and I want to remove the first seperator

    <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="http://#"> Fashion Insider</a>
                    | <a href="http://#"> Leasing</a>
    </div>

    thnx in advance

Viewing 1 replies (of 1 total)
  • Try replacing this:

    <?php echo strip_tags(wp_nav_menu( $menuParameters ), '<a>' ); ?>

    with this:

    <?php $menu = strip_tags(wp_nav_menu( $menuParameters ), '<a>' );
    $menu = preg_replace('/sub_nav.>\s+\|/','sub_nav">$1',$menu);
    echo $menu; ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Remove first seperator’ is closed to new replies.