wordpress snippets last updated   : April 14, 2014
we now have 630 snippets

Alternate odd even post class

wordpress snippet

Adding this PHP code to your wordpress theme will append odd or even classes to post_class function.

snippet :  PHPcopy
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';

jqsnipp.com | we just launched jquery snippets website