How to modify the “after” of last element in wp_nav_menu

When using wp_nav_menu how do I make it so ‘after’ => does not show on the last element of the list?

Related posts

Leave a Reply

4 comments

  1. You can hide it with CSS. For example, if your after looks like:

    <?php wp_nav_menu(array('after' => '<span>|</span>')); ?>
    

    Then your css:

    .menu-item-num span { display: none; }
    
  2. $('#menu-top-menu-1').children().last().each( function(){
        var endHtml = $(this).html().replace('<text you want to replace>','<text to replace it with>');         
        $(this).html(endHtml);
    });