I have a custom post type Holiday associated with a taxonomy Country. On my single-holiday.php, I use the taxonomy to display in the title. For example Holiday in Spain (Spain being the tax)
Rarely, but it can happen, a holiday can be in 2 taxonomy terms. Creating a problem for my title display as I use get_the_terms.
Somebody has better solution for me.
My code is as follow
$taxonomy = 'country';
$terms=get_the_terms($post->ID,$taxonomy);
if($terms) {
foreach( $terms as $termcountry ) {
?>
<h1>Holiday in <?php echo $termcountry->name;?></h1>}}