WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm building a theme on top of a starter theme (wp-bootstrap) and am having trouble getting the Nav Walker to show the current menu item. current-menu-item is not there when I use a web inspector on the output html. So therefore I can't style it.

This is the code in my template file:

       /** Loading WordPress Custom Menu  **/
       wp_nav_menu( array(
          'menu'            => 'main-menu',
          'container' => '',
          'container_class' => 'navbar-blue',
          'menu_class'      => 'nav',
          'menu_id' => 'main-menu',
          'walker' => new Bootstrapwp_Walker_Nav_Menu()
      ) ); ?>

And this is the code in function.php:

include 'includes/class-bootstrapwp_walker_nav_menu.php';

And finally this is the code from the customer nav walker file:

class Bootstrapwp_Walker_Nav_Menu extends Walker_Nav_Menu {

function __construct() {
  function start_lvl(&$output, $depth) {

$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class=\"dropdown-menu\">\n";

I've looked over a few stackexchange answers and tried changing the code to match them, but nothing has solved the issue (ie: nothing has made current-menu-item appear in the html output).

Any help would be appreciated.

share|improve this question
and you get current-menu-item when you skip the walker? – birgire Apr 2 '13 at 12:54
I've deleted the walker line in the array and still no current-menu-item. I've also tried replacing the whole array block with the default version from the wp codex and no joy. – Paul Burnhill Apr 3 '13 at 9:04
Okay, I've discovered that if I place the wp-nav-menu array in header.php, I get current-menu-item to display but my site design has the same menu code in sidebar.php and it doesn't work - any suggestions on how to fix this? header.php was the original position for the menu in the starter theme framework. – Paul Burnhill Apr 3 '13 at 9:46
maybe you need to reset the global $post value again? you could try <?php wp_reset_postdata();?> before the sidebar part. – birgire Apr 3 '13 at 10:21
Sadly no, that didn't work. Thank you for help on this by the way. – Paul Burnhill Apr 3 '13 at 10:47
up vote 0 down vote accepted

Since it is working as you expect in the header.php file (but not in sidebar.php), you could add this into header.php:

global $my_nav;
$my_nav= wp_nav_menu( array(
          'menu'            => 'main-menu',
          'container' => '',
          'container_class' => 'navbar-blue',
          'menu_class'      => 'nav',
          'menu_id' => 'main-menu',
          'walker' => new Bootstrapwp_Walker_Nav_Menu(),
          'echo' => 0,
      ) ); ?>

and then in your sidebar.php file you could add

global $my_nav;
echo $my_nav;

to display the menu.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.