-
-
Save pavlo-bondarchuk/9019422383750d1c6a882aa538f71401 to your computer and use it in GitHub Desktop.
get first term of taxonomy current post / custom post type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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