Skip to content

Snippet: Get & Display Term Thumbnail

Total has the ability to assign images to your categories/terms if you are working on some custom code and you want to grab these it's very easy, see the example below.

if ( $thumb_id = wpex_get_term_thumbnail_id() ) {
	
	$image = wpex_get_post_thumbnail( array(
		'attachment'    => $thumb_id,
		'width'         => '',              // Int: Custom image width
		'height'        => '',              // Int: Custom image height
		'crop'          => 'center-center', // Str: Crop location
		'alt'           => '',              // Str: Custom alt tag for image
		'class'         => '',              // Str: Add custom classes
		'return'        => 'html',          // Str: Return html or src
	) );

	echo $image;

}
All PHP snippets should be added via child theme's functions.php file or via a plugin.
We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top