Add Odd/Even to Posts

To add the classes “even” and “odd” to your posts, put the following snippet in your functions.php.

Code Snippet:

<?php
function oddeven_post_class ( $classes ) {
   global $current_class;
   $classes&#91;&#93; = $current_class;
   $current_class = ($current_class == 'odd') ? 'even' : 'odd';
   return $classes;
}
add_filter ( 'post_class' , 'oddeven_post_class' );
global $current_class;
$current_class = 'odd';
?>

Posted in Posts