items_wrap not working

I registered a wordpress menu this way:

function nothing_register_menus() {
  register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'nothing_register_menus' );

I am calling wp_nav_menu that way:

Read More
wp_nav_menu( array(
                'theme_location' => 'header-menu',
                'container' => false,
                'echo' => false,
                'menu_class' => 'nav-menu horiz-menu container',
                'items_wrap' => '<ul class="sixteen columns">%3$s</ul>'
            ) )

But the output always looks the same. The menu class is correct, but the wrapping ul never has a class.

Related posts

2 comments

  1. your problem is in your use 'menu_class' and 'items_wrap' not synchronized.

    You can edit :

    wp_nav_menu( array(
                    'theme_location' => 'header-menu',
                    'container' => '',
                    'echo' => '0',
                    'menu_class' => 'nav-menu horiz-menu container sixteen columns',
                    'items_wrap' => '<ul class="%2$s">%3$s</ul>'
                ) )
    

    or:

    wp_nav_menu( array(
                    'theme_location' => 'header-menu',
                    'container' => '',
                    'echo' => '0',
                    'items_wrap' => '<ul class="nav-menu horiz-menu container sixteen columns">%3$s</ul>'
                ) )
    

    Apologize for my English is bad !

  2. Straight from the codex:

    $items_wrap (string) (optional) Evaluated as the format string
    argument of a sprintf() expression. The format string incorporates the
    other parameters by numbered token. %1$s is expanded to the value of
    the ‘menu_id’ parameter, %2$s is expanded to the value of the
    ‘menu_class’ parameter, and %3$s is expanded to the value of the list
    items. If a numbered token is omitted from the format string, the
    related parameter is omitted from the menu markup. Default: %3$s

    Therefore your items_wrap should look like this:

    'items_wrap' => '<ul class="%2$s">%3$s</ul>'
    

    where %2$s will be replaced by ‘nav-menu horiz-menu container’.

    I don’t know where you expect the ‘sixteen columns’ classes to render.

Comments are closed.