I am trying to learn how to use walker_nav_menu for past week but can't find the right material. WP documentation just cover simple definition of walker nav menu class. And most of the resources i found are not really working or outdated.
My walker class:
class WP_Bootstrap extends Walker_Nav_Menu {
public function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t",$depth);
$output .= "\n$indent<ul class=\"dropdown-menu$submenu depth_$depth\">\n";
}
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
}
}
My wp nav menu:
wp_nav_menu( array(
'theme_location' => 'top',
'container' => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'navbarNav',
'menu_class' => 'navbar-nav mr-auto',
'walker' => new Wp_Bootstrap(),
) );
Why it's not working? i can't really see the output. I also want to change class of li.