Add a Second Level menu class to wordpress Nav Menu

Viewed 15

I used this code to create a new submenu class, but now I want to create a different class for the second level submenu. submenu--2 is this possible?

  add_filter( 'nav_menu_link_attributes', 'add_menu_link_class', 1, 3 );

  class Child_Wrap extends Walker_Nav_Menu
{
    function start_lvl(&$output, $depth = 0, $args = array())
    {
        $indent = str_repeat("\t", $depth);
        $output .= "$indent<ul class=\"navigation__item--submenu\" >\n";
    }

    function end_lvl(&$output, $depth = 0, $args = array())
    {
        $indent = str_repeat("\t", $depth);
        $output .= "$indent</ul>";
    }
    
}
0 Answers
Related