Skip to main content

Remove container and UL on WordPress nav menu

Sometimes you might want to programatically include other things in your menu in WordPress and to do that you will want to control the UL tags so you can insert other LI items within it.
The code below will allow you to spit out ONLY the LI tags from a WordPress Nav Menu, you will have to wrap it in UL yourself so you can add extra LI.

<ul>
<?php
wp_nav_menu(array(
      'container' => '',
      'items_wrap' => '%3$s'
));
?>
<li>Another link</li>
</ul>

Leave a Reply