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 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(
    array(
    'container' => false,
    'items_wrap' => '<ul class="nav navbar-nav">%3$s</ul>',
    'theme_location' => 'menu_principal'
    )); ?>
</nav>

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">
        <ul>
            <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>
        </ul>
    </div>
</nav>

not add the class ul why?

share|improve this question
    
What output do you get when you try the code suggested in my answer below? –  Chip Bennett Oct 28 '13 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. –  Chip Bennett Oct 28 '13 at 0:13

1 Answer 1

up vote 0 down vote accepted

Edit

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():

$menu_class

(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'
) ); ?>
share|improve this answer
    
thanks for your answer but menu_class put in div and i want in ul tag. –  user2799505 Oct 27 '13 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. –  Chip Bennett Oct 27 '13 at 23:45
    
edit question thanks. –  user2799505 Oct 28 '13 at 0:00
    
See edited answer. That output is being generated by the fallback wp_page_menu(), not by wp_nav_menu(). –  Chip Bennett Oct 28 '13 at 0:16
    
thanks. chip your answer is correct. –  user2799505 Oct 28 '13 at 0:30

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.