Skip to content

Instantly share code, notes, and snippets.

@rwdevpixelparlor
Last active January 25, 2018 19:27
Show Gist options
  • Save rwdevpixelparlor/43c30b8fdac0ea1aec1fbe5d409de01e to your computer and use it in GitHub Desktop.
Save rwdevpixelparlor/43c30b8fdac0ea1aec1fbe5d409de01e to your computer and use it in GitHub Desktop.
.even {
background:#f0f8ff;
}
.odd {
background:#f4f4fb;
}
<?php
function oddeven_post_class ( $classes ) {
global $current_class;
$classes[] = $current_class;
$current_class = ($current_class == 'odd') ? 'even' : 'odd';
return $classes;
}
add_filter ( 'post_class' , 'oddeven_post_class' );
global $current_class;
$current_class = 'odd';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment