Skip to content

Instantly share code, notes, and snippets.

@braginteractive
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save braginteractive/42ea24f852e15cd32025 to your computer and use it in GitHub Desktop.
Save braginteractive/42ea24f852e15cd32025 to your computer and use it in GitHub Desktop.
Add class to the last WordPress post
/**
* Add 'last' class to last post
* Must be using <?php post_class(); ?>
*/
function add_last_class($classes) {
global $wp_query;
if(($wp_query->current_post + 1) == $wp_query->post_count)
$classes[] = 'last';
return $classes;
}
add_filter('post_class', 'add_last_class');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment