Skip to content

Instantly share code, notes, and snippets.

@ovizii
Created July 28, 2013 08:29
Show Gist options
  • Save ovizii/6097943 to your computer and use it in GitHub Desktop.
Save ovizii/6097943 to your computer and use it in GitHub Desktop.
Add a custom class to the last post in a loop
function last_post_class($classes){
global $wp_query;
if(($wp_query->current_post+1) == $wp_query->post_count) $classes[] = ‘last’;
return $classes;
}
add_filter(‘post_class’, ‘last_post_class’);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment