Support » Themes and Templates » How to remove pipe after last navigation menu item
4 years, 2 months ago
After reading how to add ‘|’ between the navigation menu items on my Twenty eleven child theme http://www.route32.be/demaeyer/
Another question that I have is: how can I remove the ‘|’ after the last menu item? I only want it to separate the menu items but not have one at the very last.
My php code looks like this:
<?php wp_nav_menu( array( ‘theme_location’ => ‘primary’, ‘link_after’ => ‘<span class=”my-span”>|</span>’ ) ); ?>
I’ve tried all other options that I could find using CSS to define this, but I always got pipes underneath the navigation menu. Couldn’t figure out how to make this work using CSS.
In changing this php code, I’m still looking to add spaces between the menu items and the pipes, and how to remove the last pipe.
I did quite some reading online about this, and it seems to be a tricky one for many. Please help!
Basically, I’m thinking.. if I can add a character using PHP, I should be able to add a space, using PHP too… but how oh how…
that would solve my 1st problem… would still need to figure out how to remove the last pipe
When I add to the PHP code
<?php wp_nav_menu( array( ‘theme_location’ => ‘primary’, ‘link_after’ => ‘<span class=”my-span”>nbsp|nbsp</span>’ ) ); ?>
It again, gives me the spaces but also additional pipes below the navigation menu.