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

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.

share|improve this question
    
how do you see the menu output for the above code if you use 'echo' => false? –  birgire Aug 26 '13 at 12:38
    
I'm using a variable $output and echo the whole thing in the end. –  Lord_Mord Aug 26 '13 at 14:38

2 Answers 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.

share|improve this answer
    
That returns an ul without a class, too. In my understanding, it should be possible to add a custom class somehow. Just like the way is done here with the ID: wordpress.org/support/topic/menu-ul-class –  Lord_Mord Aug 26 '13 at 19:51

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 !

share|improve this answer

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.