Skip to content

Instantly share code, notes, and snippets.

@braddalton
Forked from billerickson/gist:2002741
Last active December 20, 2015 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save braddalton/6137063 to your computer and use it in GitHub Desktop.
Save braddalton/6137063 to your computer and use it in GitHub Desktop.
add_filter( 'post_class', 'be_first_post_class' );
/**
* First Post Class
* Adds a class of 'first' to the first post
*
* @author Bill Erickson
* @link http://www.billerickson.net/code/first-post-class
*
* @param array $classes
* @return array
*/
function be_first_post_class( $classes ) {
global $wp_query;
if( 0 == $wp_query->current_post )
$classes[] = 'first';
return $classes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment