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;
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;
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;