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.

I am using wp_nav_menu and I have a need for custom implementation. The default markup is like this:

<ul>
   <li id="menu-item-59" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-59"><a href="http://j2designpartnership.com/yip/about/">About</a>
         <ul class="sub-menu" style="display: none;">
                <li id="menu-item-60" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-60"><a href="http://j2designpartnership.com/yip/about/alumni-board-members/">Alumni Board Members</a></li>
         </ul>
   </li>
   <li id="menu-item-69" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-69"><a href="http://j2designpartnership.com/yip/partners/">Partners</a>
   </li>
</ul>

I need there to be a span tag before the closing ul like so:

     <span></span>
<ul>

Any idea how I can accomplish this using a walker or other function?

share|improve this question
add comment

2 Answers

First of all... I don't think that this is a good idea. Placing <span> just before closing </ul> tag will make this HTML incorrect ;)

But if you really really (really) must and there is no other way... You can use wp_nav_menu_items filter to do this.

function my_wp_nav_menu_items($items, $args) {
  return $items . '<span></span>';
}
add_filter('wp_nav_menu_items', 'my_wp_nav_menu_items');
share|improve this answer
add comment

Its in the wp_nav_menu arguments: 'items_wrap' => '<ul>%3$s<span></span></ul>'

share|improve this answer
    
Yet still adding <span> tag in this place isn't very good idea - it makes your HTML code invalid. –  Krzysiek Dróżdż Jun 19 '13 at 19:41
add comment

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.