In Category Archive

Use following code snippet to display the category image for the currently displayed category in taxonomy-wpdmcategory.php:

$category_obj = get_queried_object();
$category_metadata = maybe_unserialize( get_option(  "__wpdmcategory"  ) );
$category_image_url = $category_metadata[ $category_obj->term_id ][ 'icon' ];
echo '<img src="' . $category_image_url . '" alt="' . $category_obj->name . '" />';

Somewhere Else

Use following code snippet to display the category image for the provided category term:

$category_obj = get_term($term_id); // Make sure $term_id is set
$category_metadata = maybe_unserialize( get_option(  "__wpdmcategory"  ) );
$category_image_url = $category_metadata[ $category_obj->term_id ][ 'icon' ];
echo '<img src="' . $category_image_url . '" alt="' . $category_obj->name . '" />';
Last Updated: Jul 25, 2017


Leave a Reply