WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

At the moment I'm adding a button element around the menu anchors using this markup:

$defaults = array(
    'theme_location'  => '',
    'menu'            => 'main-nav',
    'container'       => 'ul',
    'container_class'    => 'nav navbar-nav',
    'before'          => '<button class="btn btn-warning">',
    'after'           => '</button>',
    'menu_class'      => '',
    'menu_id'         => 'menu',
    'echo'            => true,
    'fallback_cb'     => 'wp_page_menu',
    'link_before'     => '',
    'link_after'      => '',
    'items_wrap'      => '<div class="col-md-6 col-md-offset-3">%3$s</div>',
    'depth'           => 0,
    'walker'          => ''
wp_nav_menu( $defaults );

How would I add the btn btn-warning classes to the menu links automatically?

Here is an example of my site

share|improve this question
Why do you have to use a button element? You can have <a> elements that look like warning buttons in bootstrap – Tom J Nowell Aug 13 '14 at 15:22
Well, that's the thing... I can't specify a class for the <a> elements. and what I've tried does not work. Do you have any ideas? – Kyle Poyser Aug 13 '14 at 15:37
The site you linked to has button elements wrapped around anchor elements though? How is what you're trying to do different from what you already have? – Tom J Nowell Aug 13 '14 at 16:01
Because For some reason my current method (for the buttons) is not working in ie or Firefox... Test is out please my site – Kyle Poyser Aug 13 '14 at 19:16
I figure if the a link specifies a class="btn btn-warning" then i would not have to wrap the anchor element inside the <button></button>. – Kyle Poyser Aug 13 '14 at 19:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.