用于注入<span>
在菜单中,您可以使用以下代码进行操作:
//Setup this code into your current function.php file
add_filter(\'wp_nav_menu_items\',\'add_span_in_menu\', 10, 2);
function add_span_in_menu( $items, $args ) {
if( $args->theme_location == \'primary\') {
$myContent = \'YOURCONTENT\'
$items .= \'<li><span class="number">\' . $myContent . \'</span></li>\';
}
return $items;
}
上面的代码段将添加
<span>
将内容添加到您的WordPress菜单。希望这对你有帮助!