Support » Themes and Templates » having trouble with wp_nav_menu walker function

  • It is giving me error: Notice: Trying to get property of non-object in D:\xampp\htdocs\…\wp-includes\nav-menu-template.php on line 153 & 156.

    My code is below:
    ———————————–

    wp_nav_menu(
        array(
            'theme_location' => 'primary',
            'menu_class' => 'navbar-collapse collapse',
            'walker' => new Primary_Walker_Nav_Menu()
        )
    );
    
    class Primary_Walker_Nav_Menu extends Walker_Nav_Menu {
        function start_lvl( &$output, $depth = 0, $args = array() ) {
            $indent = str_repeat("\t", $depth);
            $output .= "\n" . $indent . "<ul class=\"dropdown-menu\">" . "\n";
        }
    }

    Can you guys please help me on this?

    Thanks,
    Prayas Sapkota

  • The topic ‘having trouble with wp_nav_menu walker function’ is closed to new replies.