I have been using this question to try to do this but I am having some difficutlty. I have a custom post type, media, and I am working on the archive-media.php template.
I have it partially working in that when I delete the if condition out of the code it does add the class, but of course to every post. I have determined that $wp_query->current_post
is not returning a value, so I feel I must not be using this right. I have the code in my functions.php file. The codex says that current_post is available in the loop, so I am a bit confused.
add_filter('post_class', 'my_post_class');
function my_post_class($classes){
global $wp_query;
if(($wp_query->current_post+1) == $wp_query->post_count) $classes[] = 'last';
return $classes;
}