I have made a page template which shows linked subpages using this bit of code:
<?php
$mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'menu_order', 'sort_or
foreach( $mypages as $page ) {
$content = $page->post_content;
if ( ! $content ) // Check for empty page
continue;
$content = apply_filters( 'the_content', $content );
?>
<h2><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a><
<div class="entry"><?php echo $content; ?></div>
<?php
}
?>
I got the code from here and have changed it to order subpages in the order of their Page Order.
It works, but it displays the full pages’ contents. I only want it to show page excerpts, with the featured image.
(I have enabled page excerpts in the editor by adding add_post_type_support( 'page', 'excerpt' );
to functions.php)
How do I modify this page template to show subpage excerpts?
Slightly modify these lines
to
UPDATE:
for adding featured image use
A reworked example of your snippet
This sample shows you how you can make use of plugins that hook their actions into filters or hooks. It also allows to use password protection for the child post incl. default core translation strings.