WordPress 在索引页面上显示子菜单项
我正在使用 wordpress,在“sidebar.php”页面上我有以下代码:
<?php wp_list_pages('post_type=wiki&depth=1'); ?>
它工作得很好,但我需要做的是,我单击侧边栏上的菜单项时,我需要将子项目显示在主屏幕上页。
更新:
我基本上需要做的是将第一级项目放在左侧(目前是这样),当单击这些链接时,这些项目的子项目将列在index.php(主页)上。
我正在使用 wp-wiki 插件将页面显示为 wiki 页面,但实际列表是相同的,只是显示为不同的类型:
post_type=wiki
有人可以帮忙吗?
谢谢
I am using wordpress and on the page "sidebar.php" I have the following code:
<?php wp_list_pages('post_type=wiki&depth=1'); ?>
It works great but what I need to do it that what I click on a Menu item on the sidebar I need the sub items to display on the main page.
UPDATE:
What I basically need to do is to have the first level items on the left (As it currently is), and when those links are clicked then the sub items of those items will be listed on the index.php (main page).
I am using the wp-wiki plugin to display the pages as wiki pages but the actual but the list is the same, just showing as a different type:
post_type=wiki
Can anyone help please?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有多种方法可以实现此目的。 WordPress 实际上有一个示例,正是您希望在 Codex 中执行的操作。 (链接 - 该部分的最后一个示例,位于“列出子页面甚至如果在子页面上”标题)
有几种方法可以做到这一点 - 这只是一个例子。但是上面的代码,您只需弹出到 sidebar.php 文件中即可。您还可以用它创建一个小部件。正如其他人提到的,您可以使用 WordPress 的新菜单系统(但您确实可以使其动态化。)但 Codex 中的上述示例是最简单的方法。
实际上,更简单的方法就是列出所有子页面,并使用 CSS 根据您所在的页面隐藏和显示子项目。课程已经为您设置好了。只要查看你的源代码就可以看到。所以你会做类似的事情:
及其变体。
There's several ways you can accomplish this. WordPress actually has an example of exactly what you're looking to do in the Codex. (link - the last example in that section, right above the "List subpages even if on a subpage" heading)
There's several ways to do this though - that's just one example. But that code above, you just pop into your sidebar.php file. You can also create a widget out of it. And as someone else mentioned, you can use the new menu system for WordPress (but you can indeed, make it dynamic.) But the above example in the Codex is the simplest method.
Actually, an easier method would be just to list all subpages and use CSS to hide and show the child items based on what page you're on. The classes are already set up for you. Just view your source code and you can see it. So you'd do something like:
and variations thereof.
使用 wp 3 中的新菜单功能怎么样?
这样,您就可以将您的类型包含在您想要的任何子页面中(尽管不会是动态的),然后添加您最喜欢的 javascript 或良好的 css 来显示这些子页面。
What about using the new menu function in wp 3?
That way you could include your type with any sub page you want (won't be dynamic though) and then add your favorite javascript or good css to show those sub-pages.