使用参数before
和after
:
wp_nav_menu(
array(
\'theme_location\' => \'primary\',
\'menu_class\' => \'nav-menu\',
\'before\' => \'<span>\',
\'after\' => \'</span>\'
)
);
要查看这些参数是如何使用的,请查看方法
start_el()
在里面
Walker_Nav_Menu
:
$item_output = $args->before; // \'before\'
$item_output .= \'<a\'. $attributes .\'>\';
$item_output .= $args->link_before . apply_filters( \'the_title\', $item->title, $item->ID ) . $args->link_after;
$item_output .= \'</a>\';
$item_output .= $args->after; //\'after\'