Sometimes it’s just not feasible to have the sub (or child) pages listed within your sidebar in WordPress, especially if you have a lot of child pages. However, instead of needing to manually add each link to its parent page, you can quickly do it with a bit of PHP goodness. Using the following code within your page.php file will add a list of all the sub pages to the currently viewed parent page.

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

Please note that the above code must be used within the WordPress loop in order to work. (I personally prefer to put it right after <?php the_content(); ?> so it will display the list of sub pages after the page content.)

To remove the sub pages from showing under the parent pages in the sidebar, add ‘depth=1′ in addition to any other variables in the wp_list_pages() code within your sidebar. Example: <?php wp_list_pages(’title_li=&depth=1′); ?>