delarge
10/10/2016 - 2:22 PM

Get first taxonomy term for post - and add a link

Get first taxonomy term for post - and add a link

$terms = get_the_terms( $post->ID, 'mytaxonomy' );
//returns an array of taxonomy term objects, so

$term = array_pop($terms);
//Would give you the first term in the array. And then:

echo '<a href="'.get_term_link($term->slug, 'mytaxonomy').'">'.$term->name.'</a>'