wp-bootstrap-navwalker icon indicating copy to clipboard operation
wp-bootstrap-navwalker copied to clipboard

code to make it default for all menus

Open eduardoarandah opened this issue 11 years ago • 3 comments

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

eduardoarandah avatar Jul 17 '15 21:07 eduardoarandah

No, to my knowledge this is not possible.

SideQuestDIY avatar Jul 20 '15 00:07 SideQuestDIY

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.

pattonwebz avatar Aug 07 '15 20:08 pattonwebz

Epic! I will add this to the documentation for the next version.

SideQuestDIY avatar Aug 31 '15 17:08 SideQuestDIY