wordpress get current taxonomy code example
Example 1: get current term id
term_id; ?>
Example 2: wordpress get terms by taxonomy
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,
]);
Example 3: wordpress get current taxonomy
$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