• Hello,

    I tried posting in the ‘Advanced Development’ area of this forum, but unfortunately, the forum was closed to new topics.

    I am new to the Walker Classes in WordPress and currently trying to use said classes for creating my menu. I am following a YouTube tutorial, and have got to the stage whereby I have placed the below code in my ‘walker.php’ file:

    class Walker_Nav_Primary extends Walker_Nav_Menu {
    
    	function start_lvl( &$output, $depth ){ /* Handles opening of the <ul> tags.*/
    		$indent = str_repeat("\t",$depth);
    		$submenu = ($depth > 0)? ' sub-menu' : '';
    		$output .= "\n$indent<ul class=\"dropdown-menu$submenu depth_$depth\">\n";
    	}

    Unlike the YouTube tutorial, when I insert the above code, my drop down menus are not visible.

    Has anyone come across an issue like this before and aware of how to resolve such a matter?

    Any help, regarding this matter, would be greatly appreciated.

    Thanks.

    Craig

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You landed in the right place, any custom coding questions belong in Hacks.

    Is your walker.php file included or required in functions.php? Did you instantiate your class and pass the object as an argument in the theme’s call of wp_nav_menu()?

    Even if you have no use for the wp_nav_menu() arguments, for full compatibility, your method should collect the arguments and specify defaults anyway.
    public function start_lvl( &$output, $depth = 0, $args = array() ) {

    Then sometime down the road you can easily plug your class into any theme without errors or conflicts.

Viewing 1 replies (of 1 total)
  • The topic ‘Drop Down Menus not visible with the Walker Class’ is closed to new replies.