要获得这种控制,您可能需要创建一个自定义助行器。查看的默认值wp_nav_menu()
$defaults = array(
\'theme_location\' => \'\',
\'menu\' => \'\',
\'container\' => \'div\',
\'container_class\' => \'\',
\'container_id\' => \'\',
\'menu_class\' => \'menu\',
\'menu_id\' => \'\',
\'echo\' => true,
\'fallback_cb\' => \'wp_page_menu\',
\'before\' => \'\',
\'after\' => \'\',
\'link_before\' => \'\',
\'link_after\' => \'\',
\'items_wrap\' => \'<ul id="%1$s" class="%2$s">%3$s</ul>\',
\'depth\' => 0,
\'walker\' => \'\'
);
您需要创建一个新的助行器,并在其中加载
\'walker\' => \'\'
论点有
an example toward the middle of the page, 如果你搜索的话,这里有很多Q/A。
由于看起来您正在破解一个主题,我建议创建一个儿童主题,并通过wp_nav_menu_args
filter.
$args = apply_filters( \'wp_nav_menu_args\', $args );