Get the first post term

I’m not sure what you mean by ‘first’ taxonomy… but,

$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>,'

(You may want to include some if statements, in case an empty array or error is returned (see is_wp_error)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)