For Bootstrap, implementing WordPress menu is a bit tricky. It needs a Custom Walker Menu class to be implemented.
Here’s a complete tutorial how you can implement a WordPress Nav Menu with Bootstrap:
- How to Integrate Bootstrap Navbar Into WordPress Theme by Kateryna Belyaeva
The Custom Walker Class can be found here on GitHub:
- wp-bootstrap-navwalker – Github by Edward McIntyre
But on this integration, please note:
The following code block is important, where we are accepting only 2 level of the menu. The Bootstrap 3.0 developers choose the max level of a navbar menu to be 2 level deep.
<?php /* Primary navigation */
wp_nav_menu( array(
'menu' => 'top_menu',
'depth' => 2,
'container' => false,
'menu_class' => 'nav',
//Process nav menu using our custom nav walker
'walker' => new wp_bootstrap_navwalker())
);
?>
If you want multilevel menu, then Edward also provided a technique for Bootstrap 2.3.2 with multi-level support:
- Multilevel Bootstrap Navbar – Gist by Edward McIntyre