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 trying to list the custom taxonomy term that is attached to the post in question (which is a custom post type). I want to list it without it being a link, it is in fact a title.

I've tried this, but it clearly doesn't work. What am I doing wrong?

function woocommerce_output_product_brand() {

$terms = get_the_terms( $post->ID, 'brand' );
foreach($terms as $term){
    echo $term; }

Thanks in advance!

share|improve this question
up vote 2 down vote accepted

First of all, what is $post? If you after the global $post, then you have to declare the global in the function. So on the second line you'll need to put global $post;.

Secondly, $term is an object. If you are after the term's name, use $term->name, for it's slug $term->slug.

See the Codex for some examples of how to use get_the_terms

share|improve this answer
Thanks for your help, I used get_the_term_list instead. – Jacob Mar 6 '12 at 3:20

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.