Add a class to the first post on the first page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'post_class', 'generate_first_post_class' ); | |
function generate_first_post_class( $classes ) | |
{ | |
global $wp_query; | |
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; | |
if( 0 == $wp_query->current_post && 1 == $paged ) | |
$classes[] = 'first'; | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment