WordPress – Show a list of child pages on the parent page

Sometimes is can be useful to show a list of child pages in the parent page. This is easy to do using WordPress.

1. Select Appearance > Editor.
2. On the right hand side under Templates there should be a functions.php option, click this.
3. Scroll to the bottom of the functions.php file which should have opened in the central box.
4. Copy and paste the following:

function wpb_list_child_pages() { 

global $post; 

if ( is_page() && $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('wpb_childpages', 'wpb_list_child_pages');

5. Click the Update File button
6. Open the page you want the child list to appear on and enter the following Shortcode

[wpb_childpages]