我想将循环分成总循环数的一半。如果总循环数为奇数,我想删除最后一个数组项,以使总循环数为偶数,并将删除的项添加到后半部分。
这是演示循环的代码结构-
<?php
$faqs = new WP_Query( array (
'post_type' => 'faq'
));
?>
<div class="row">
<div class="col-lg-6">
<!-- The first half of the tootal loop count. -->
<?php
while ($faqs->have_posts()) : $faqs->the_post();
the_content();
endwhile();
?>
</div>
<div class="col-lg-6">
<!-- The second half of the tootal loop count. -->
<?php
while ($faqs->have_posts()) : $faqs->the_post();
the_content();
endwhile();
?>
</div>
</div>
我不知道如何根据我提到的条件控制循环。这就是我无法尝试循环控制的原因。
慕少森