Sometimes WordPress developers or users want to make their latest post looks different from the rest for their theme. This can be done by adding new class to the latest post and then styling the class via css. Add this code in the function.php.
[code lang=”php”]
function firstpost_class($class) {
global $post;
if( 0 == $post->current_post )
$class[] = ‘first’;
return $class;
}
add_filter(‘post_class’, ‘firstpost_class’);
[/code]
Now, the first post has new class, ‘firstpost’ and we can style the latest post by using this class.