Skip to content

Instantly share code, notes, and snippets.

@chrisrouse
Created May 10, 2013 12:49
Show Gist options
  • Save chrisrouse/5554217 to your computer and use it in GitHub Desktop.
Save chrisrouse/5554217 to your computer and use it in GitHub Desktop.
Adds a custom class to the last post in a loop
// Add a 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