我有一个 HTML 菜单,我想用 wp_nav_menu 在 Wordpress 中显示它。
的HTML
<nav id="navigation" class="ddsmoothmenu">
<ul id="main-menu">
<li><a href="index.html" class="current"><span>Home</span></a>
<ul>
<li><a href="index-2.html">Home Alternate 2</a></li>
<li><a href="index-3.html">Home Alternate 3</a></li>
<li><a href="index-4.html">Home Alternate 4</a></li>
<li><a href="index-5.html">Home Alternate 5</a></li>
<li><a href="index-6.html">Home Alternate 6</a></li>
</ul>
</li>
</ul>
我在我的 Wordpress header.php 文件中添加以下内容以显示导航菜单
$defaults = array(
'theme_location' => 'primary',
'menu' => 'Primary Menu',
'container' => '',
'container_class' => '',
'container_id' => '',
'menu_class' => 'menu',
'menu_id' => '',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'before' => '',
'after' => '',
'link_before' => '<span>',
'link_after' => '</span>',
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
'depth' => 0,
'walker' => ''
);
wp_nav_menu($defaults);
然而,输出也在菜单项的第二级添加标签
<nav id="navigation" class="ddsmoothmenu">
<ul id="main-menu">
<li><a href="index.html" class="current"><span>Home</span></a>
<ul>
<li><a href="index-2.html"><span>Home Alternate 2</span></a></li>
<li><a href="index-3.html"><span>Home Alternate 3</span></a></li>
<li><a href="index-4.html"><span>Home Alternate 4</span></a></li>
<li><a href="index-5.html"><span>Home Alternate 5</span></a></li>
<li><a href="index-6.html"><span>Home Alternate 6</span></a></li>
</ul>
</li>
</ul>
有没有办法只为顶级菜单项添加跨度或从二级菜单项中删除跨度?