WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the following code to display the term for a specified taxonomy:

$terms = get_terms( "book_review" );
$category = $terms[0]->name;

However I want to display the term for whatever the currently displayed taxonomy is, rather than specifying a particular taxonomy. Basically what I'm wanting is a way to replicate the functionality of get_the_category, but for the current taxonomy instead of the current category. I'm trying to display this on a single custom post type page (single-custom_post_type_name.php)

share|improve this question
What context? The taxonomy page (URL=/your-taxonomy/your-term/), or somewhere else? – MikeSchinkel Apr 5 '11 at 1:30
I updated the question with the context. – Industrial Themes Apr 5 '11 at 13:24
up vote 2 down vote accepted

You can use get_queried_object to get the term name.

<?php if( is_tax() ) {
    global $wp_query;
    $term = $wp_query->get_queried_object();
    $title= $term->name;

}  ?>

To display: <?php echo $title; ?>

If your on a taxonomy archive page you can use:

<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); ?>

Then to display the term: <?php echo $term->name; ?>

The following properties are available for the $term object:

  • term_id
  • name
  • slug
  • term_group
  • term_taxonomy_id
  • taxonomy
  • description
  • parent -count
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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