Skip to content

Instantly share code, notes, and snippets.

@cerkit
Last active January 2, 2016 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cerkit/de5884b307f1977e5555 to your computer and use it in GitHub Desktop.
Save cerkit/de5884b307f1977e5555 to your computer and use it in GitHub Desktop.
Bootstrap Navbar on WordPress with merged menus
<nav id="top-navbar" class="navbar navbar-default navbar-fixed-top" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/" rel="home">
My Website
</a>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse-1">
<ul class="nav navbar-nav">
<?php
/* Show the primary menu
*/
wp_nav_menu( array(
'menu' => 'primary',
'theme_location' => 'primary',
'container' => false,
'depth' => 2,
'items_wrap' => '%3$s',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker())
);
/* Create a social menu that displays icons for social networks
* it is special because it needs to integrate with the existing links
*/
wp_nav_menu( array(
'menu' => 'social',
'theme_location' => 'social',
'container' => false,
'depth' => 1,
'items_wrap' => '%3$s',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker())
);
?>
</ul>
</div>
</nav>
@cerkit
Copy link
Author

cerkit commented Jan 2, 2016

Example uses twittem/wp_bootstrap_navwalker as a custom menu walker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment