在侧边栏中显示子页面和子子页面
所以,我有一个带有多个子页面的父页面。一些子页面有子子页面。我希望能够在父页面上仅显示所有子页面。如果您转到子页面,它将仍然显示父级的所有子页面,但现在还会显示当前子页面的子子页面。
我现在拥有的功能几乎可以做到这一点,但还缺乏。 它将显示所有子页面,如果您进入子页面,它将显示子子页面,但如果您进入子子页面,它将仅显示所有其他子子页面,并停止显示子页面。
<?php
if($post->post_parent)
$children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->post_parent."&echo=0");
else
$children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0&depth=1");
if ($children) {
?>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>
有谁知道我可以尝试做什么来实现这项工作? 这是它应该如何输出的快速想法。
*Parent Page* ( does not need to display anything, just a marker of the current page I am on )
- Sub Page 1
- Sub Page 2
- Sub Page 3
*Sub Page 1* ( does not need to display anything, just a marker of the current page I am on )
- Sub Page 1
- Sub Sub Page 1
- Sub Sub Page 2
- Sub Page 2
- Sub Page 3
*Sub Sub Page 1* ( does not need to display anything, just a marker of the current page I am on )
- Sub Page 1
- Sub Sub Page 1
- Sub Sub Page 2
- Sub Page 2
- Sub Page 3
So, I have a Parent page with multiple Sub Pages. Some of the Sub Pages have Sub Sub Pages. I want to be able to, on the Parent page, only display all the Sub Pages. If you go to a Sub Page it will display all of the Parent's Sub Pages still, but now also display the Sub Sub Pages of the current Sub Page.
The current function I have now does almost that, but it's lacking.
It will display all of the Sub Pages, if you go to a SUb Page, it will display the Sub Sub Pages, but if you get to the Sub Sub Page, it will only display all the other Sub Sub Pages, and stops displaying the Sub Pages.
<?php
if($post->post_parent)
$children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->post_parent."&echo=0");
else
$children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0&depth=1");
if ($children) {
?>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>
Does anyone have an idea of what I could try to make this work?
This is a quick idea of how it should output.
*Parent Page* ( does not need to display anything, just a marker of the current page I am on )
- Sub Page 1
- Sub Page 2
- Sub Page 3
*Sub Page 1* ( does not need to display anything, just a marker of the current page I am on )
- Sub Page 1
- Sub Sub Page 1
- Sub Sub Page 2
- Sub Page 2
- Sub Page 3
*Sub Sub Page 1* ( does not need to display anything, just a marker of the current page I am on )
- Sub Page 1
- Sub Sub Page 1
- Sub Sub Page 2
- Sub Page 2
- Sub Page 3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为 折叠页面插件 可以满足您的需求。
I think the Fold Page Plugin does what you want.
谢谢@Kalessin,但该插件自 2008 年以来就没有更新过。
我最终使用了 Simple部分导航小部件
Thanks @Kalessin, but that plugin hasn't been updated since 2008.
I ended up using Simple Section Navigation Widget