How to get the excerpts of all children pages

Firstly, it should be post_excerpt.

Secondly, this just stores the manually added excerpt, so it returns empty if you don’t have one.

Thirdly, you could setup_postdata:

<?php $pagechildren = get_pages( array( 'child_of' => $post->ID ) ); ?>
<?php foreach ( $pagechildren as $post ) : 
    setup_postdata( $post ); ?>
        // code
<?php endforeach;
    wp_reset_postdata(); ?>

Do not forget to reset – wp_reset_postdata().

If you use setup_postdata(), then you can use e.g. get_the_excerpt()

setup_postdata( $post );
$excerpt = get_the_excerpt();

As @birgire correctly noted usage of $post – instead of $child – is a must to use the template tags available reliably.

Leave a Comment