Customize icon for each post category, tag, taxonomy term

With Content Views Pro, you can show the icon before categories list of post.
But if you want to use custom icon for each category, or tag… Please add this code to file functions.php of your active theme:

// Content Views Pro - customize icon of taxonomy
add_filter( 'pt_cv_post_term_html', 'cvp_theme_custom_tax_icon', 10, 2 );
function cvp_theme_custom_tax_icon( $args, $term ) {
	$icon = '';
	if ( $term->slug === 'blog' ) {
		$icon = 'icon_html_here';
	}
	if ( $term->slug === 'videos' ) {
		$icon = 'icon_html_here';
	}

	$href		 = esc_url( get_term_link( $term, $term->taxonomy ) );
	$term_name	 = esc_attr( $term->name );
	$class		 = esc_attr( PT_CV_PREFIX . 'tax-' . $term->slug );
	$args		 = "<a href='$href' title='$term_name' class='$class'>{$icon}{$term->name}</a>";

	return $args;
}

Please replace blog, videos with slugs of your categories, replace icon_html_here with an image, or span HTML…

Best regards,

Scroll to Top