Displaying Child Pages on the Parent Page in WP with a shortcode

To display child pages on a parent page in WordPress just edit theme’s functions.php file and and the following code:

 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' );
$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );
if ( $childpages ) {
$string = '</code>
<ul>' . $childpages . '</ul>
return $string;
add_shortcode('wpb_childpages', 'wpb_list_child_pages');

Then add the [wpb_childpages] shortcode wherever you need to display child pages. ;)

If you need to Display Child Pages Without Any Shortcode dinamically, you need to add this line of code where you want to display child pages:

The theme will now automatically detect child pages and display them.

Mariusz Szatkowski