Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add a class to the first post on the first page
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
You can’t perform that action at this time.