如何将子菜单下拉菜单添加到当前的 wp 主题顶部菜单?
我创建了一个新的 WP 主题,并在标题中插入了顶部菜单/导航...但它只有 1 级深度。
我该如何修改它以便以下拉样式显示子页面?
这是当前的代码:
<div class="header_right">
<ul>
<?php wp_list_pages('title_li=&depth=1'); ?>
<li><a href="#" id="signin"></a></li>
</ul>
</div>
谢谢
I have created a new WP Theme and in the header have inserted a top menu / nav ... but it's just 1 level depth.
How do I modify this so that I have show subpages in a dropdown style please?
Here is the current code:
<div class="header_right">
<ul>
<?php wp_list_pages('title_li=&depth=1'); ?>
<li><a href="#" id="signin"></a></li>
</ul>
</div>
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用
depth=0
获取整个页面列表,包括嵌套在分层li
元素中的子页面。此外,您还必须编写相应的 CSS 代码,以便子菜单页面以下拉样式显示。您可以参考任何具有相同菜单风格的主题。 211 主题有一个非常简单的菜单,具有此功能和易于理解的 CSS 代码。
You need to use
depth=0
to get the entire list of pages including sub-pages nested in heirarchicalli
elements. Also, you will have to write corresponding CSS code for the sub-menu pages to appear in drop-down style.You can take any theme having the same menu style as reference. Twenty Eleven theme has a very simple menu with this functionality and easy to understand CSS code.
对于您的标题使用:wp_nav_menu();
要获得鼠标悬停时下拉的下拉子菜单,您需要在上一行添加一些代码:
paste-bin 添加子菜单
功能 WordPress 帮助博客
For your header use: wp_nav_menu();
To get dropdown sub menus that dropdown when hovered over you'll want to add some code to the previous line:
paste-bin adding sub-menu
There's some very helpful advice and useful CSS at Capability Wordpress Help Blog