wordpress obține taxonomia unui post
<?php $term_obj_list = get_the_terms( $post->ID, 'taxonomy_name' ); ?>
NU
// RETRIVE TERM SLUG ( for single.php or template-part )
$terms = get_the_terms( $post->ID, 'your-taxonomy' );
if ( !empty( $terms ) ){
// get the first term
$term = array_shift( $terms );
echo $term->slug;
}
obțineți ID-ul de termen prin id-ul poștal
INSIDE TAXONOMY PAGES
$term = get_queried_object();
$term_id = $term->term_id;
NU
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,
]);