Posted By

hstothard on 02/08/10


Tagged

wordpress


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

maxvee8
kirichev


Wordpress - Add last class to every 4th post


 / Published in: PHP
 

  1. <?php if (have_posts()) : ?>
  2. <?php $count = 0; ?>
  3. <?php while (have_posts()) : the_post(); ?>
  4.  
  5.  
  6. <?php if ($count % 4 == 3) { ?>
  7. <div class="post last">
  8. <?php } else { ?>
  9. <div class="post">
  10. <?php } ?>
  11.  
  12. <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  13. <div class="entry">
  14. <?php the_content(); ?>
  15.  
  16. </div>
  17. </div>
  18.  
  19. <?php $count++; ?>
  20. <?php endwhile; ?>
  21. <?php endif; ?>

Report this snippet  

You need to login to post a comment.