Last active
August 29, 2015 14:01
-
-
Save anneallen/3a60a953ecccd561e0af to your computer and use it in GitHub Desktop.
Add Zebra stripping class to every 2nd post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //*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