Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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>
<div class="row>
<div>4th post</div>
</div>
...Repeat

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

share|improve this question

marked as duplicate by toscho Oct 1 '12 at 1:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    

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; ?>
share|improve this answer

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