I need to add a different class for last post of a Custom Post Type. Is it possible?
I have found this code, but it works only in posts
function wpc_last_post_class( $classes ) {
global $wp_query;
if(($wp_query->current_post+1) == $wp_query->post_count) $classes[] = 'last'; // change the class name you would like to add here
return $classes;
}
add_filter('post_class', 'wpc_last_post_class');
post_class()
function in the template file responsible for displaying the custom post type?post_class()
in your template, or you're not using the main query.