继承我的代码:
<?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();
?>
它应该显示“事件”页面的所有子页面,而是显示自己几次。我已经仔细查看了代码,尝试了不同的调整以使其工作,但到目前为止还没有。任何帮助将非常感谢!
答案 0 :(得分:1)
当然,正如我发布的那样,我想出来......我不得不改变这个:foreach($ events as $ page):setup_postdata($ page ); ?&GT;对此:foreach($ events as $ post):setup_postdata($ post ); ?&GT;