0

I have a hierarchical taxonomy with lots of terms in hierarchical order.

No matter what term i'm viewing I'd like to be able to display the custom taxonomy name (as per what i've registered it as singular_name) on that page. I've searched here and the WP forums to death but had no luck.

I found this but it only displays the slug, not the name...

$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );    
echo $term->taxonomy; 
2

get_taxonomy( $taxonomy_name ) will give you an object containing all of the taxonomy metadata:

$queried_object = get_queried_object();
$this_tax = get_taxonomy( $queried_object->taxonomy );
echo $this_tax->labels->singular_name;
  • @JacobPeattie true, it's a partial taxonomy object, but not nearly complete, depending on what you're after. – Milo Jan 26 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.