I am using the following code to list the child pages of current page on my sidebar. It is working very well.
$titlenamer = get_the_title($post->post_parent);
$output = wp_list_pages('echo=0&depth=1&title_li=<div id="list-title-head">'.$titlenamer.'</div>' );
if (is_page( )) {
$page = $post->ID;
if ($post->post_parent) {
$page = $post->post_parent;
}
$children=wp_list_pages( 'echo=0&child_of=' . $page . '&title_li=' );
if ($children) {
$output = wp_list_pages ('echo=0&child_of=' . $page . '&title_li=<div id="list-title-head">'.$titlenamer.'</div>');
}
}
echo $output;
But If a parent menu has no childs, this code will list all the parent pages on my sidebar. How can I control this?
If the parent menu doesn't have any childs, then I wants to display certains pages I define. If this is not possible, I don't want to display anything for page that doesn't have childs.