If I configure wp_nav_menu function, I can put the "items_wrap" option to achieve a nice navigation given by Twitter Bootstrap, thus: <ul class="nav nav-pills">%3$s</ul>. But, how to configure the custom menu widget to do the same? I mean, for achieve <ul class="nav nav-tabs nav-stacked">%3$s</ul> in all custom menu widgets, by default.

Thanks for help! Have a nice day.


Filter 'wp_nav_menu_args'.

add_filter( 'wp_nav_menu_args', 'wpse_79901_nav_menu' );

function wpse_79901_nav_menu( $args )
    $args['items_wrap'] = '<ul class="nav nav-pills">%3$s</ul>';
    return $args;
  • Great! But that would affect all existing item_wrap of each wp_menu_nav() defined and I just want to change item_wrap to custom menu widget ... I decided to make the following, tell me if it's the best way to do it: if(!$args['fallback_cb']){ $args['items_wrap'] = '<ul class="nav nav-pills">%3$s</ul>'; } return $args;. Works for me, but I don't know if it's the best way to do it. Jan 10 '13 at 5:47
  • @markotom That’s exactly how it should be done. :)
    – fuxia
    Jan 10 '13 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.