Last active
August 29, 2015 14:11
-
-
Save srikat/5da1e24bc1737f2982f6 to your computer and use it in GitHub Desktop.
Alternate border colors for Posts in WordPress. http://sridharkatakam.com/alternate-border-colors-posts-wordpress/
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/odd post class for Posts in Posts page, Archives and Search results | |
| add_filter( 'post_class', 'sk_even_odd_post_class' ); | |
| function sk_even_odd_post_class( $classes ) { | |
| global $wp_query; | |
| if ( is_home() || is_archive() || is_search() ) { | |
| $classes[] = ($wp_query->current_post % 2 == 0) ? 'odd' : 'even'; | |
| } | |
| return $classes; | |
| } |
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
| .odd.entry { | |
| border: 5px solid #288eb0; | |
| } | |
| .even.entry { | |
| border: 5px solid #eeac18; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment