如何将子菜单下拉菜单添加到当前的 wp 主题顶部菜单?

发布于 2024-12-07 04:31:38 字数 326 浏览 2 评论 0原文

我创建了一个新的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凯凯我们等你回来 2024-12-14 04:31:38

您需要使用 depth=0 获取整个页面列表,包括嵌套在分层 li 元素中的子页面。此外,您还必须编写相应的 CSS 代码,以便子菜单页面以下拉样式显示。

您可以参考任何具有相同菜单风格的主题。 211 主题有一个非常简单的菜单,具有此功能和易于理解的 CSS 代码。

You need to use depth=0 to get the entire list of pages including sub-pages nested in heirarchical li 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.

撩人痒 2024-12-14 04:31:38

对于您的标题使用: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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文