答案 0 :(得分:0)
你可以使用css nth child,但更好的做法是使用你已经用来查询帖子的php循环上的计数器。使用模运算,您可以使用不同的css类区分每个第四项和其余项。 例如:
<div class="posts-grid">
<?php
$counter=1;
$class=null;
$posts=g et_posts( 'numberposts=-1&order=ASC');
foreach( $posts as $post ) :
if ($counter % 4==0 ) {
$class= full-width;
} else {
$class= third-width;
}
?>
<div class="post-item <?php echo $class; ?>">
...
</div>
<?php $counter++; endforeach; ?>
</div>
&#13;