Add class to first post in the wp loop

add_filter( 'post_class', 'jeba_first_post_class' );
function jeba_first_post_class( $classes ) {
    global $wp_query;
    if( 0 == $wp_query->current_post )
        $classes[] = 'first-post';
        return $classes;
}

Leave a Reply