Two suggestions:
- To output your “Loop” only for Child Pages, and not for Grandchild etc. Pages, add a conditional.
e.g.
foreach ( $mypages as $page ) {
if ( $page->post_parent == $post->ID ) {
// Loop goes here
}
}
- To output only an excerpt of each Child Page, enable excerpt support for Pages, and then output
$page->post_excerpt
.
In functions.php
:
add_post_type_support('page', 'excerpt');
Then in your “Loop”:
foreach ( $mypages as $page ) {
if ( $page->post_parent == $post->ID ) {
$content = $page->post_excerpt; // changed post_content to post_excerpt
if( ! $content ) // Check for empty page
continue;
$content = apply_filters( 'the_content', $content );
?>
<h2><a href="https://wordpress.stackexchange.com/questions/16791/<?php echo get_page_link( $page->ID ) ?>"><?php echo $page->post_title ?></a></h2>
<div class="entry"><?php echo $content ?></div>
<?php
}
}