I intend to create a sidebar to retrieve a list of the current page's children as well as the current page itself. Here is the code that I have been using which retrieves the current pages children even when on the child pages, however when I try to include the $parent
as $post->post_parent
it displays all pages
<?php
if ($post->post_parent) {
$ancestors=get_post_ancestors($post->ID);
$root=count($ancestors)-1;
$parent = $ancestors[$root];
} else {
$parent = $post->ID;
}
$children = wp_list_pages("title_li=&child_of=". $parent ."&echo=0");
$parent = wp_list_pages("title_li=&child_of=". $post->post_parent ."&echo=0");
if ($children) { ?>
<ul class="tabs">
<?php echo $parent ?>
<?php echo $children; ?>
</ul>
<?php } ?>