Skip to content

Instantly share code, notes, and snippets.

@jbutko
Created May 26, 2013 20:52
Show Gist options
  • Save jbutko/5653990 to your computer and use it in GitHub Desktop.
Save jbutko/5653990 to your computer and use it in GitHub Desktop.
PHP, WP: Add different class to every nth post (3rd)
<?php if (have_posts()) : ?>
<?php $c = 0;while (have_posts()) : the_post(); $c++;
if( $c == 3) {
$style = 'third';
$c = 0;
}
else $style='';
?>
<div <?php post_class($style) ?> id="post-<?php the_ID(); ?>">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment