Skip to content

Instantly share code, notes, and snippets.

@dospuntocero
Created September 9, 2018 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dospuntocero/1b1832f5c55ee6cf94f52986618e3007 to your computer and use it in GitHub Desktop.
Save dospuntocero/1b1832f5c55ee6cf94f52986618e3007 to your computer and use it in GitHub Desktop.
add this function to your functions.php class and then add the filter to the result you need to have it.
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