[Support request] New menu location

Home Forums Support New menu location

This topic contains 1 reply, has 2 voices, and was last updated by  Tom 2 months, 1 week ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1195845

    jose

    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?

    #1196526

    Tom Lead Developer

    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/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.