Monthly Archives: April 2012

WordPress and child page listing

Sometimes I want a listing of the child pages to be embedded in the text of a page. This could be done manually but then maintenance of the site is a nightmare (unless it is a really static site!)

So adding the following code into the relevant page template for the WordPress site works a treat.

$children = wp_list_pages(‘title_li=&child_of=’.$post->ID.’&echo=0′);
if ($children) { ?>
<?php echo $children; ?>
<?php } ?>

While it is not a rule, this related page listing is probably going to appear underneath any of the page text content, so look for the following in the page template and place the child page code below this line.

<?php the_content(); ?>