Skip to content

Instantly share code, notes, and snippets.

@anneallen
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save anneallen/3a60a953ecccd561e0af to your computer and use it in GitHub Desktop.

Select an option

Save anneallen/3a60a953ecccd561e0af to your computer and use it in GitHub Desktop.
Add Zebra stripping class to every 2nd post
//*Add "even" class to every 2nd post/CBT
function aa_archive_post_class( $classes ) {
// Don't run on single posts or pages
if( is_singular() )
return $classes;
global $wp_query;
if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 2 )
$classes[] = 'even';
return $classes;
}
add_filter( 'post_class', 'aa_archive_post_class' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment