WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

   <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>
   <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>

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


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

share|improve this question

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

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

Your Answer


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.