Enter your keyword

Blog

How to Add Odd and Even CSS Classes to WordPress Posts

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';

No Comments

Add your review

Your email address will not be published.

* Feilds are Required.