I have a custom taxonomy called cities and right now the only city is las vegas. I am trying to use the code in question to echo "Las Vegas" - for the posts that are associated - on the search results page, taxonomy page and single post page.
Las vegas wouldnt be the only city, but each post should only be associated with 1 city therefore I just need the term associated with the post. As of now with the code Im using, the term is echoing for every post, even those not in the "City" category.
<?php $terms = get_terms( 'city-type' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
echo '<span>' . $term->name . '</span>';
}
}; ?>
Im using in the loop, what am I doing wrong?