Add category/tag/taxonomy term to HTML class of posts in grid

To add taxonomy term slug (category, tag, custom) as HTML class of the wrapper div of each item in the grid, please add this code to file functions.php of your active theme:

// Content Views Pro - Add taxonomy term name to post's class
add_filter( 'pt_cv_content_item_class', 'cvp_theme_term_name_as_class', 100, 2 );
function cvp_theme_term_name_as_class( $args, $post_id ) {
	$taxonomies	 = get_taxonomies( '', 'names' );
	$terms		 = wp_get_object_terms( $post_id, $taxonomies );
	foreach ( $terms as $term ) {
		$args[] = sanitize_html_class( "cvp-term-{$term->taxonomy}-{$term->slug}" );

	return $args;

Best regards,

Scroll to Top