Possible Duplicate:
How to mark every 3rd post

Is it possible to style every four posts differently? I mean something like this:

<div class="row">
<div>1st post</div>
<div>2nd post</div>
<div>3rd post</div>
<div class="row>
<div>4th post</div>

I'm using cssgrid, so it would be great if I could experiment more with that.. :)


1 Answer 1


Standard Loop:

<?php while ( have_posts() ) : the_post(); ?>    
    <?php get_template_part( 'content', get_post_format() ); ?>    
<?php endwhile; ?>

Loop checking for 4th post:

<?php $i = 0; while ( have_posts() ) : the_post(); $i++; ?>        
    <?php if(!$i%4): get_template_part( 'content', get_post_format() . '-4th' ); ?>
    <?php else: get_template_part( 'content', get_post_format() ); endif; ?>
<?php endwhile; ?>

Not the answer you're looking for? Browse other questions tagged or ask your own question.