-
-
Save About2git/a60e906c1fb5c66015df to your computer and use it in GitHub Desktop.
Alternate border colors for Posts in 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