Skip to content

Instantly share code, notes, and snippets.

@ericjames
Created July 1, 2017 21:09
Show Gist options
  • Save ericjames/3f6308272a448d1c260c5cb3a63290d5 to your computer and use it in GitHub Desktop.
Save ericjames/3f6308272a448d1c260c5cb3a63290d5 to your computer and use it in GitHub Desktop.
Wordpress List Child Pages with Thumbnails
<?php if (is_page('web-design')) : ?>
<?php $i = 0; ?>
<div>
<ul>
<?php
$args = array(
'post_parent' => $post->ID,
'post_type' => 'page',
'post_status' => 'publish',
'orderby' => 'menu_order',
'order' => 'ASC',
'numberposts' => -1,
);
$postslist = get_posts($args);
foreach ($postslist as $post) :
setup_postdata($post);
$i++;
?>
<li>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<div><a href="<?php the_permalink(); ?>"><?php if( has_post_thumbnail() ) the_post_thumbnail('thumbnail'); ?></a></div>
<div>
<?php the_excerpt(); ?> &mdash;<a href="<?php the_permalink(); ?>">Read more</a>
</div>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment