【发布时间】:2015-08-31 09:57:05
【问题描述】:
我在这里有一个循环,它正在发布我的自定义帖子类型的完整列表 - 但是,每第四个循环我都会尝试打印一个 clearfix,这就是我想出的,但它要么在每个循环中打印它,要么根本没有——有人可以帮忙吗?干杯
<?php
$args = array(
'post_type' => 'custom',
'numberposts' => '-1',
'post_status' => 'publish',
'order' => 'ASC'
);
$postslist = get_posts($args);
foreach ($postslist as $post) :
setup_postdata($post);
for ($counter = 1; $counter < 100; $counter++ ) {
if ($counter % 4 == 0) {
echo "<div class='clearfix'></div>";
}
}
?>
【问题讨论】: