Skip to content

Instantly share code, notes, and snippets.

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

  • Save srikat/5da1e24bc1737f2982f6 to your computer and use it in GitHub Desktop.

Select an option

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/
//* 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;
}
.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