Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

3 Answers 3

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; }
share|improve this answer

While this can be done with JS, it might be more tidy to use wp_nav_menu filter, through which final output of menu is passed before returning/echoing.

share|improve this answer
1  
You should expound on this –  Carey Estes Feb 28 '13 at 4:00
$('#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);
});
share|improve this answer
    
Can't edit, but also need to change #menu-top-menu-1 to your menu ID –  Jeff Mar 1 '11 at 20:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.