I have a custom post type (dibujos) and 4 custom taxonomy.

I would like to get term name in a current post.

The probleme is, how to To display the name of the taxonomy, no matter what taxonomy is.

The code is:

<?php   // Get terms for post
 $terms = get_the_terms( $post->ID , 'my-taxonomy' );
 // Loop over each item since it's an array
 if ( $terms != null ){
 foreach( $terms as $term ) {
 // Print the name method from $term which is an OBJECT
 print $term->name ;
 // Get rid of the other data stored in the object, since it's not needed
} } ?>


  • I don't really understand this - you know the name of your taxonomy - you're specifying it in the get_the_terms() call. What exactly do you want to do?
    – anu
    Sep 5, 2012 at 7:37
  • 1
    Hi, I have 4 different taxonomy. How to know the taxonomy in the current post?
    – Aina
    Sep 5, 2012 at 9:16
  • I think you need to reframe the question. The code sample you've picked specifically chooses terms from a single taxonomy. Do you want to get all terms from all taxonomies?
    – anu
    Sep 5, 2012 at 9:25
  • No, i need the current term, not all terms. THKS
    – Aina
    Sep 7, 2012 at 5:13
  • Your question makes no sense - please edit it to be very clear whether you want to know the name of the taxonomy or the term.
    – anu
    Sep 7, 2012 at 7:03

3 Answers 3


You can use wp_get_object_terms($object_ids, $taxonomies, $args) to get all terms from a defined set of taxonomies for an object

The $taxonomies parameter can be an array of taxonomy names.



Hi, I have 4 different taxonomy. How to know the taxonomy in the current post?

Nope, you cannot get the taxonomy name on single.php. What are you trying to achieve with this? You probably need to look at a problem from a different angle.

  • 1
    Hi, I try to get a navigation path (like a breadcrumbs). For example: If i'm looking for a house i would like to put a link to see all houses. I try with $wp_query->queried_object->name but nothing happend.
    – Aina
    Sep 7, 2012 at 5:12

Opsss Sorry I made a mess.

Put this code by each taxonomy

<?php if( false != get_the_term_list( $post->ID, 'my-taxonomy' ) ) {
     echo '<li>'.(__('Ver más:')) . get_the_term_list($post->ID,'my-taxonomy', ' ', ' ', '' ).'</li>'; }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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