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!
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 putglobal $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