Skip to content

Instantly share code, notes, and snippets.

@pavlo-bondarchuk
Created December 22, 2018 21:08
Show Gist options
  • Save pavlo-bondarchuk/9019422383750d1c6a882aa538f71401 to your computer and use it in GitHub Desktop.
Save pavlo-bondarchuk/9019422383750d1c6a882aa538f71401 to your computer and use it in GitHub Desktop.
get first term of taxonomy current post / custom post type
$terms = get_the_terms( $post->ID, 'taxonomy-name' );
if( $terms ){
$term = array_shift( $terms );
// echo name or slug
echo $term->name; //or
echo $term->slug;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment