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;
}
The following two tabs change content below.

Md Jahed

Latest posts by Md Jahed (see all)

Leave a Reply

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