Add “odd” “even” Class Name to “post_class”

/*
 * Add "odd" "even" Class Name to "post_class"
 */
function odd_even_post_class( $classes ) {
    global $oddeven_class;

    $oddeven_class = ( $oddeven_class == 'odd' ) ? 'even' : 'odd';
    $classes[] = $oddeven_class;

    return $classes;
}

add_filter( 'post_class', 'odd_even_post_class' );

Leave a Reply

Your email address will not be published. Required fields are marked *