Listing Excerpts From Child Pages

Now you wouldn’t normally need to display an excerpt from a page’s description, would you? I didn’t think so either. But apparently there is a need. And when there’s a need, we aim to please. We had a client who wants to display custom excerpts from a page’s child pages on the parent page with links to the child page. WordPress normally doesn’t excerpt from pages, only from posts.

So we had to find a plugin that would do that. Enter PJW Page Excerpt by Peter Westwood. Once you install this plugin, there’s nothing to configure. You just go to the page where you want to add an excerpt and you’ll notice an excerpt box just like you’d see on a post entry page. How cool is that?

The next step is to add your custom excerpts to all your page’s child pages. Then watch the magic.

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<?php $parent = $post->ID; ?>
<h2 class="title"><?php the_title(); ?></h2>
<?php the_content('<p>strong>Read the rest of this page &raquo;</strong>'); ?>
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
<?php endwhile; endif; ?>
<ul class="about-excerpts">
<?php while (have_posts()) : the_post(); ?>
<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
<?php the_excerpt(); ?>
<?php endwhile; ?>

Notice that I’ve added styling hooks to the unordered list. This is because I don’t want a list-style-type, but rather a nice inline paragraph. And that lets me style the output however I want. Hope this helps someone else!