Heres my code:
<?php
$args = array(
'child_of' => 15,
'sort_order' => 'DESC',
'sort_column' => 'post_date',
'post_type' => 'page',
'post_status' => 'publish' );
$events = get_pages( $args );
if (have_posts()) :
while (have_posts()) : the_post();
foreach ( $events as $page ) : setup_postdata($page); ?>
<?php if (has_post_thumbnail( $post->ID ) ); ?>
<?php $date = get_the_date( $d ); ?>
<div id="post">
<div class="post_excerpt">
<a href="<?php echo get_page_link( $post->ID ); ?>"><h2><?php the_title(); ?> / <?php echo $date; ?></h2></a><?php echo the_ID($post->ID); ?>
<p><?php the_excerpt(); ?></p>
</div>
<div class="post_thumb">
<a href="<?php echo get_page_link( $post->ID ); ?>"><?php the_post_thumbnail(); ?></a>
</div>
<div class="post_line"></div>
</div>
<?php
endforeach;
endwhile;
endif;
wp_reset_postdata();
?>
It should be displaying all the child pages of the “Events” page, but instead its showing itself a few times. I’ve looked through the code over and over trying different tweaks to get it to work, but nothing has so far. Any help would be very appreciated!
Of course just as I post this I figure it out… I had to change this: foreach ( $events as $page ) : setup_postdata($page); ?> to this: foreach ( $events as $post ) : setup_postdata($post); ?>