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:
<?php
/** 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.
Since it is working as you expect in the
header.php
file (but not insidebar.php
),you could add this into
header.php
:and then in your
sidebar.php
file you could addto display the menu.