If you're using a page template, you should do the following things:
- Create a global variable at the top of your page template (which I'm assuming you're using)
- Get the ID of the queried object and assign it to that variable
- Globalize the variable in your sidebar.php file
- Use the variable in the get_posts or query_posts function to display child pages (the correct parameter to use is
post_parent
)
So, put this at the top of your page template:
<?php
global $xyz_queried_object_id, $wp_query;
$xyz_queried_object_id = $wp_query->get_queried_object_id();
?>
And then put this in your sidebar:
<h2><?php _e( 'Subpages') ?></h2>
<ul>
<?php
global $xyz_queried_object_id;
$subpages = new WP_Query(array('post_type'=>'page','post_parent'=>$xyz_queried_object_id));
while( $subpages->have_posts() ) {
$subpages->the_post();
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php
}
?>
</ul>
That should get you what you want.