I have enabled the excerpt feature for pages in my wordpress theme -

add_action( 'init', 'my_add_excerpts_to_pages' );
    function my_add_excerpts_to_pages() {
         add_post_type_support( 'page', 'excerpt' );

This has enabled the excerpt box when adding or updating pages through the admin area, which is what I expected.

I am then trying to display each excerpt on the homepage of my site like so -

$child_pages = $wpdb->get_results("SELECT *    FROM $wpdb->posts WHERE post_parent  = 64    AND post_type = 'page' ORDER BY post_title", 'OBJECT');    ?>
            <?php if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?>
            <div class="memberHover" id="member-<?php echo $pageChild->ID; ?>">
              <div><h4><?php echo $pageChild->post_title; ?></h4>
                <p><?php the_excerpt(); ?></p>
              </div><?php echo get_the_post_thumbnail($pageChild->ID, '312,156'); ?>
        <?php endforeach; endif; ?>

The issue is that even if I have a manual excerpt populated through the admin area, it still creates the auto excerpt when displaying on the homepage. It seems that it is not picking up the fact that there is a custom excerpt in the database for each item.

Any and all help is greatly appreciated!

Thanks, Tristan

  • does the manual excerpt work in posts? if not, then there could be a plugin conflict.
    – Michael
    Commented Feb 28, 2012 at 13:29

3 Answers 3


Because I am very particular about how to do things in Wordpress when it comes to looping, I couldn't help but want to post a better way to do the above loop in your question as seeing the way you've done it looks like a lot of unnecessary work for yourself.

You already answered your own question but for the sake of being able to use the function the_excerpt() I've rewritten the above code to work using the WP_Query object instead which I believe is a better way of going about loop related matters (not to mention easier). You really only need to use manual queries like that when you want to query something the WP_Query class cannot.

$args = array('post_parent' => 64, 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'page', 'post_status' => 'publish');
$child_pages = new WP_Query($args);

<?php if ($child_pages->have_posts()): ?>

<?php while($child_pages->have_posts()): $child_pages->the_post(); ?>
            <div class="memberHover" id="member-<?php the_ID(); ?>">
              <div><h4><?php the_title(); ?></h4>
                <p><?php the_excerpt(); ?></p>
              </div><?php echo get_the_post_thumbnail($post->ID, '312,156'); ?>
<?php endwhile; ?>

<?php endif; ?>
  • 1
    Thanks very much :) I'll mark this as the answer instead.
    – TGuimond
    Commented Mar 1, 2012 at 11:47

I've had this issue before. The way you handled it is correct, but you can also do this which is essentially the same, (but a little different):

<?php echo get_the_excerpt();?>

Fixed :)

I updated <p><?php the_excerpt(); ?></p> to be <p><?php echo $pageChild->post_excerpt; ?></p> and this solved the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.