您可以扩展菜单漫游器,并在具有子菜单的项目上添加“has\\u children”类:
class My_Walker_Nav_Menu extends Walker_Nav_Menu{
public function display_element($el, &$children, $max_depth, $depth = 0, $args, &$output){
$id = $this->db_fields[\'id\'];
if(isset($children[$el->$id]))
$el->classes[] = \'has_children\';
parent::display_element($el, $children, $max_depth, $depth, $args, $output);
}
}
并将类的实例作为参数传入
wp_nav_menu()
:
wp_nav_menu(array(
\'theme_location\' => \'whatever\',
\'walker\' => new My_Walker_Nav_Menu(),
));
然后用CSS添加箭头,如Philip发布的:
li.has_children > a:after { content: " →"; }