Hi there. I'm trying display a list of pages that includes any given page's parent, siblings and children, something like this:
- Parent
- Page
- Child 1
- Child 2
- Sibling
- Page
I'm not able to use wp_list_pages in it's simplest form, because the Parent page also has siblings. I've been trying to use the example on the Template Tags/wp list pages page in the Codex, but, although it works fine for the parent and sibling pages, when I go to the child pages, only those child pages are listed, giving me:
- Child 1
- Child 2
This is the code I'm currently using:
<?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 } ?>
Is it at all possible to adapt this code to take into account more than one level of children e.g. using 'ancestor' rather than 'parent'? (You can probably tell I know enough php to copy and paste without the template imploding, but not enough to reverse engineer the code myself :)
Any help very much appreciated!