This is an old version of this answer!
Return to the current answerYou need to see if the $post->post_parent has childrens. The code below should do the trick.
<?php
if($post->post_parent){
//get the parrent and see if it'a a top page (has no parent)
$parent = get_page($post->post_parent);
if($parent->post_parent){ //if it's not a top page, then his parent should be
$children = wp_list_pages('title_li=&child_of='.$parent->post_parent.'&echo=0');
}else{
$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) { ?>
<h2><?php
$parent_title = get_the_title($post->post_parent);
echo $parent_title;
?></h2>
<ul>
<?php echo $children; ?>
</ul>
<?php }
?>
Valentinas Bakaitis | 08/07/10 at 12:31pm





