Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.