//Get selected terms of a post by taxonomy
$selectedTerms = wp_get_post_terms(get_the_ID(),'TAXONOMY_NAME');
foreach($selectedTerms as $term){
echo $term->name;
}
You need to pass an additional argument to get_terms(). The default is to hide
"empty" terms-- terms which are assigned to no posts.
$terms = get_terms([
'taxonomy' => $taxonomy,
'hide_empty' => false,
]);
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
echo $term->name; // will show the name
echo $term->slug; // will show the slug
$obj = get_queried_object();
echo $obj->term_id;