0

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?

2 Answers 2

1

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

1
  • Yet still adding <span> tag in this place isn't very good idea - it makes your HTML code invalid. Jun 19, 2013 at 19:41
0

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');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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