Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner 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
You can’t perform that action at this time.