Skip to content

Instantly share code, notes, and snippets.

@psflannery
Created May 10, 2013 16:15
Show Gist options
  • Save psflannery/5555461 to your computer and use it in GitHub Desktop.
Save psflannery/5555461 to your computer and use it in GitHub Desktop.
Adds a class to every nth post -- Wordpress
<?php if (have_posts()) : ?>
<?php $c = 0;while (have_posts()) : the_post(); $c++;
if( $c == 3) {
$style = 'third';
$c = 0;
}
else $style='';
// this goes in the loop
?>
<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