我还没有对此进行测试,但看起来您只需要设置一个迭代变量(通常缩写$i
), 像这样:
<?php
$i = 0; // This sets your variable
$query = [
\'post_type\' => \'post\',
\'posts_per_page\' => 5
];
$query = new WP_Query($query);
while ($query->have_posts()) : {
$query->the_post();
if($i == 0) :
get_template_part(\'loops/acc-cards\');
else() :
get_template_part(\'loops/cards\');
}
$i++ // This iterates the iteration variable $i
wp_reset_postdata();
?>