Support » Fixing WordPress » Twentyeleven Child: How to remove last pipe character from nav menu

  • Resolved kubegusa


    I have a Twentyeleven child theme

    I added code to the header.php to add the pipe character ‘|’ between the nav menu items

    <?php wp_nav_menu( array( 'theme_location' => 'primary', 'link_after' => '<span class="my-span">|</span>' ) ); ?>

    And I added this CSS code to style it

    	margin-left: 0.5em; /*adds space left btw navi menu items*/
    	margin-right: 0.5em; /*adds space right btw navi menu items*/
    	color: white; /*make white pipe*/

    But how do I remove the last pipe character from the nav menu?
    I tried the solutions offered on this forum and elsewhere, but nothing worked for me.

    Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Try this CSS:

    .menu-item-17 .my-span {
        display: none;

    When you add more to the menu, you will need to edit the menu-item number but for now, that CSS should work.

    Oh my god, you’re a star! I spent HOURS looking to fix this. Thanks so much!

    No problem!

    somehow this solution doesn’t work anymore for another project… I’ve been trying to understand your code but it’s not clear to me where you get the 17 from and how it defines what it does (hope that makes sense)
    so troubleshooting is not a success so far

    any pointers would be greatly appreciated

    I also wonder if it makes more sense that I start learning to make a theme from scratch rather than working with child themes every time.. twentyeleven feels very complicated and elaborate

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Twentyeleven Child: How to remove last pipe character from nav menu’ is closed to new replies.