1

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!

3

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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