wp_nav_menu 在有子级的菜单后添加span

Published
2022-05-11
浏览次数 :  174

/*
*
* Walker for the main menu 
*
*/
add_filter( 'walker_nav_menu_start_el', 'add_arrow',10,4);
function add_arrow( $output, $item, $depth, $args ){

//Only add class to 'top level' items on the 'primary' menu.
if('primary' == $args->theme_location && $depth === 0 ){
    if (in_array("menu-item-has-children", $item->classes)) {
        $output .='<span class="sub-menu-toggle"></span>';
    }
}
    return $output;
}

  • 标签1
  • 标签1
  • 标签1
Top