I want to set a default featured image for terms of a custom taxonomy.
I found this code but it is only good for categories and not for other terms:
<?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail())) : ?>
<?php the_post_thumbnail('thumbnail'); ?>
<?php else :?>
<img src="whatever/directory/<?php $category = get_the_category(); echo $category[0]->cat_name; ?>.jpg" />
<?php endif;?>
How can I make this code also work for a custom taxonomy?
Instead of using
get_the_category()
use get_terms()so something like this: