Skip to content

Instantly share code, notes, and snippets.

@wp-kitten
Last active August 29, 2015 14:17
Show Gist options
  • Save wp-kitten/f16b1b74e434060fdbcc to your computer and use it in GitHub Desktop.
Save wp-kitten/f16b1b74e434060fdbcc to your computer and use it in GitHub Desktop.
Bootstrap menu in WordPress
<?php
/*
Update button's data-target="#wpk-top-menu" attribute to match the wp_nav_menu's container_id key
*/
?>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target="#wpk-top-menu" aria-expanded="false" aria-controls="navbar">
<span class="sr-only"><?php _e('Toggle navigation', 'TEXT_DOMAIN');?></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><?php _e('Project Name', 'TEXT_DOMAIN');?></a>
</div>
<?php wp_nav_menu( array(
'theme_location' => 'primary', // @see: register_sidebar()
'menu_id' => 'primary-menu',
'container_id'=>'wpk-top-menu',
'container_class'=>'collapse navbar-collapse',
'menu_class'=>'nav navbar-nav',
) ); ?>
</div>
</nav>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment