Lego2012
12/13/2016 - 4:21 PM

Add Odd and Even alternate classes to entries

Add Odd and Even alternate classes to entries

<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add odd/even post class
function sample_oddeven_post_class ( $classes ) {
  global $current_class;
  $classes[] = $current_class;
  $current_class = ($current_class == 'odd') ? 'even' : 'odd';
  return $classes;
}
add_filter ( 'post_class' , 'sample_oddeven_post_class' );
global $current_class;
$current_class = 'odd';