wp-bootstrap-navwalker
wp-bootstrap-navwalker copied to clipboard
code to make it default for all menus
Would it be possible to add a hook in my functions.php file to make every menu implement this feature?
Why: Menu widgets in sidebars ignore this walker
No, to my knowledge this is not possible.
There is a filter available for modifying what is passed to wp_nav_menu(); that you can use to do this:wp_nav_menu_args. Adding this to your theme's functions.php file should make every menu default to using this walker.
function global_custom_walker( $args ) {
return array_merge( $args, array(
'walker' => new wp_bootstrap_navwalker(),
) );
}
add_filter( 'wp_nav_menu_args', 'global_custom_walker' );
Look at this excelent answer for a bit more info.
Epic! I will add this to the documentation for the next version.