WordPress Nav Walkers to implement Bootstrap navbars.
- PHP 5.4+
- WordPress 4.4+
Easy installation with Composer.
composer require indigotree/wp-bootstrap-nav-walker
Update wp_nav_menu()
to use the IndigoTree\BootstrapNavWalker\Three\WalkerNavMenu
walker. For example:
<?php
wp_nav_menu([
'theme_location' => 'primary',
'depth' => 2,
'container' => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'primary-navbar-collapse',
'menu_class' => 'nav navbar-nav',
'fallback_cb' => '__return_empty_string',
'walker' => new \IndigoTree\BootstrapNavWalker\Three\WalkerNavMenu()
]);
Update wp_nav_menu()
to use the IndigoTree\BootstrapNavWalker\Four\WalkerNavMenu
walker. For example:
<?php
wp_nav_menu([
'theme_location' => 'primary',
'depth' => 2,
'container' => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'primary-navbar-collapse',
'menu_class' => 'navbar-nav',
'fallback_cb' => '__return_empty_string',
'walker' => new \IndigoTree\BootstrapNavWalker\Four\WalkerNavMenu()
]);
The MIT License (MIT).