WordPress.org

Ready to get started?Download WordPress

Forums

Remove first seperator (2 posts)

  1. code_rum
    Member
    Posted 1 year ago #

    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

  2. vtxyzzy
    Member
    Posted 1 year ago #

    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; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic