List WordPress child pages


Basics

To list child page of current page start by adding following code to  your functions.php or plugin. This will create a shortcode that list childpages of current page if it has them.

//Shortcode to list childpages
function xiong_list_child_pages() { 

global $post; 

if ($post->post_parent )

    $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );
else
    $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );

if ( $childpages ) {

    $string = '<ul>' . $childpages . '</ul>';
}

return $string;

}

add_shortcode('xiong_childpages', 'xiong_list_child_pages');

Then all you need to do is to add shortcode to your template.

<?php echo do_shortcode(' [xiong_childpages]' );?>