This is going to be an exciting article about WordPress post classes. You can use your own post classes to design a posts in specific order. Today I will show you how to add event and odd class to your posts. It’s super simple. Just add the following code snippets inside your theme’s functions.php file and you are done!

// add odd and even class 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';