在侧边栏中显示子页面和子子页面

发布于 2024-10-21 03:09:34 字数 1192 浏览 1 评论 0原文

所以,我有一个带有多个子页面的父页面。一些子页面有子子页面。我希望能够在父页面上仅显示所有子页面。如果您转到子页面,它将仍然显示父级的所有子页面,但现在还会显示当前子页面的子子页面。

我现在拥有的功能几乎可以做到这一点,但还缺乏。 它将显示所有子页面,如果您进入子页面,它将显示子子页面,但如果您进入子子页面,它将仅显示所有其他子子页面,并停止显示子页面。

<?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 技术交流群。

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

发布评论

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

评论(2

源来凯始玺欢你 2024-10-28 03:09:34

我认为 折叠页面插件 可以满足您的需求。

I think the Fold Page Plugin does what you want.

_失温 2024-10-28 03:09:34

谢谢@Kalessin,但该插件自 2008 年以来就没有更新过。

我最终使用了 Simple部分导航小部件

Thanks @Kalessin, but that plugin hasn't been updated since 2008.

I ended up using Simple Section Navigation Widget

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