我需要为菜单设置这样的布局,其中子元素将与其父元素分开。请参见下面的代码示例。
标准wp_nav_menu()无法解决此问题,并且 wp_get_nav_menu_items()完全平坦
<nav class="header-main-menu">
<div class="wrapper">
<div class="level-1" data-level="1">
<ul>
<li data-target="alias-2">
Parent 1
// Here is where WP puts the child by default
</li>
<li data-target="alias-2">
Parent 2
</li>
</ul>
</div>
<div class="level-2" data-level="2">
// I need to put all child menus here, with alias of parent
<ul data-alias="alias-1">
<li>
Child of 1
</li>
<li>
Child of 1
</li>
</ul>
<ul data-alias="alias-2">
<li>
Child of 2
</li>
<li>
Child of 2
</li>
</ul>
</div>
</div>
</nav>
代码示例将受到高度赞赏