Php 孙子孙女的Wordpress导航

Php 孙子孙女的Wordpress导航,php,wordpress,templates,wordpress-theming,Php,Wordpress,Templates,Wordpress Theming,我目前正在使用此代码(根据法典)在父页面上显示子页面,并在其子页面上显示父页面的子页面: <?php if($post->post_parent) $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else $children = wp_list_pages("title_li=&child_of=".$post->ID.

我目前正在使用此代码(根据法典)在父页面上显示子页面,并在其子页面上显示父页面的子页面:

<?php if($post->post_parent)
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
  else
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
  if ($children) { ?>
    <ul>
    <?php echo $children; ?>
    </ul>
<?php } ?>

我想补充一下,如果在第二个子页面(孩子的孩子),然后显示它的父母和父母的兄弟姐妹

谢谢你的帮助!:D


<?php
if($post->post_parent)
{
    //get the parent post
    $parent = get_post($post->post_parent);
    //check to see if we have a grandparent
    if($parent->post_parent)
    {
        $page_list = wp_list_pages( array( 'child_of' => $parent->post_parent, 'echo' => false, 'depth' => 1 ) );   
    }
    else
    {
        $page_list = wp_list_pages( array( 'child_of' => $post->post_parent, 'echo' => false, 'depth' => 1 ) );
    }
}
else
     $page_list = wp_list_pages( array( 'child_of' => $post->ID, 'echo' => false, 'depth' => 1 ) );
if ($page_list) { 
?>
<ul>
<?php echo $page_list; ?>
</ul>
<?php } ?>

这将检查帖子是否有父项,然后检查帖子是否有父项。
$page\u列表
应该是父级及其同级的页面列表。
'depth'=>1
告诉WordPress只获取一级页面。这将阻止它获取这些页面的子页面

hmm,这如何与我已有的代码一起工作?我仍然需要用于父页面和子页面的代码。。你能给我举个例子吗?太棒了!非常感谢你!!