i work with bootstrap3 and wordpress 3.6 but upgrade to 3.7 function wp_nav_menu not work correctly.

i use 3.6

<nav class="navbar navbar-inverse">
    <?php wp_nav_menu(
    'container' => false,
    'items_wrap' => '<ul class="nav navbar-nav">%3$s</ul>',
    'theme_location' => 'menu_principal'
    )); ?>

but this code no work in 3.7 not add ul class nav navbar-nav. why? thanks.

<nav class="navbar navbar-inverse">
    <div class="menu">
            <li class="page_item page-item-7"><a href="http://localhost:8888/wordpress2/?page_id=7">Blog</a></li>
            <li class="page_item page-item-9"><a href="http://localhost:8888/wordpress2/?page_id=9">contacto</a></li>

not add the class ul why?

  • What output do you get when you try the code suggested in my answer below? Commented Oct 28, 2013 at 0:07
  • Also: are you sure this is the same menu? You're passing 'container' => false, but the rendered output has <div class="menu">, which suggests to me that you're looking at a different wp_nav_menu() output. Commented Oct 28, 2013 at 0:13

1 Answer 1



In this case, it appears that the problem is that you're not actually outputting a custom nav menu at all, but rather the menu fallback: wp_page_menu(). Notice that the classes for the list items are page-item rather than menu-item. That's a sure giveaway that the output is being generated by wp_page_menu() rather than wp_nav_menu().

Solution: Ensure that you have created a custom nav menu, and assigned it to the menu_principal Theme Location.

Original Answer

Long answer, short: you're using the correct method to modify menu_class, and in the process, likely stepping on changes that were made to wp_nav_menu() between WordPress 3.6 and 3.7.

Instead of messing with items_wrap, you need to be manipulating menu_class, which is the correct parameter for defining the class applied to the menu element output by wp_nav_menu():


(string) (optional) The class that is applied to the ul element which encloses the menu items. Multiple classes can be separated with spaces. Formerly known as $wrap_class.

Default: menu

Try this:

<?php wp_nav_menu( array(
    'container' => false,
    'menu_class' => 'nav navbar-nav',
    'theme_location' => 'menu_principal'
) ); ?>
  • thanks for your answer but menu_class put in div and i want in ul tag. Commented Oct 27, 2013 at 23:34
  • No, the <div> is the container, the class for which is controlled by container_class. The menu_class parameter adds the specified class to the list element <ul>. P.S. please edit your question to include actual code used, along with the rendered output. Commented Oct 27, 2013 at 23:45
  • See edited answer. That output is being generated by the fallback wp_page_menu(), not by wp_nav_menu(). Commented Oct 28, 2013 at 0:16

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.