Archived topic
New menu location
1 reply · Started by jose on March 15, 2020
I am working with custom-class-walker-nav-menu.php.
To functions i added:
function cro_register_nav_menu() {
register_nav_menu( 'mega-menu', 'Mega Menu' );
}
add_action( 'after_setup_theme', 'cro_register_nav_menu' );
function register_custom_nav_walker(){
require_once 'custom-class-walker-nav-menu.php';
}
add_action( 'after_setup_theme', 'register_custom_nav_walker' );
My custom-class-walker-nav-menu.php its just the same as wordpress default class-walker-nav-menu.php
When i put the primary navigation menu to show sub-menu onclick, doesnt work.
I can see how sfHover is added, but "toggled-on" its not added to "ul.sub-menu"
Any reason?
Hi there,
My custom-class-walker-nav-menu.php its just the same as wordpress default class-walker-nav-menu.php
That doesn't sound right. Are you trying to add a custom walker to the primary navigation?
You can apply a custom walker to the primary navigation like this:
add_filter( 'wp_nav_menu_args', function ( $args ) {
if ( 'primary' === $args['theme_location'] ) {
$args['walker'] = new Your_Custom_Walker_Class();
}
return $args;
} );
Then the Your_Custom_Walker_Class needs to have the necessary changes you need.
You can learn more about creating a walker here: https://www.ibenic.com/how-to-create-wordpress-custom-menu-walker-nav-menu-class/