0
我的页面下面的结构,我需要有那些谁拥有子页面的页面显示的相同的结构:保持页面层次结构中wp_list_pages,即使对孩子或孙子
- Childpage
- - Grandchildpage
- - Other Grandchildpage
- Other Childpage
以下代码用于在page.php上显示结构:
<ul class="sidemenu-list">
<?php
if($post->post_parent)
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=1");
else
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=1");
if ($children) { ?>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>
</ul>
这适用于父页面。但是,当我在其中一个子页面或孙子页面上时,这不再起作用。
按照上面的结构例子,当我在 'Childpage' 我只得到如下:
- Childpage
- Other Childpage
当我在 'Grandchildpage' 我只得到:
- - Grandchildpage
- - Other Grandchildpage
甚至当页面是孩子或孙子时,显示页面层次结构的正确方法是什么?