• Hello,
    I’m trying to set the class on the ul element generated by the wp_nav_menu function.

    I’m using this php code:
    <?php wp_nav_menu(array('menu_class' => 'menuclass', 'container_class' => 'containerclass')); ?>

    I’d expect it to apply ‘menuclass’ to the ul, and ‘containerclass’ to the container div… But it doesn’t. It prints like this:

    <div class="menuclass">
    <ul>
    <li class="current_page_item"><a title="Home" href="#">Page 1</a></li>
    <li><a href="#">Page 2</a>
    </ul>
    </div>

    Is this a bug in the way the function works, or is the documentation incorrect?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Yup, having the same problem.

    If the menu (WP admin area) is not set, then the “menu_class” is applied to “container”.
    In other words, it overwrites the “container_class”.

    If the menu is set, then the “menu_class” is applied to “ul”.

    I’m guessing this is a bug as it doesn’t make any sense at all.

    Ah, its because of the fallback to wp_page_menu function if there is no menu set.

    You are right, it’s because of the fallback to wp_page_menu.

    But, how can I set options for wp_page_menu when wp_nav_menu falls back?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp_nav_menu() 'menu_class' usage? (bug?)’ is closed to new replies.