206 posts
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 50 and 99 users
  • Sold between 50 000 and 100 000 dollars
  • United States
mlando says

I cannot seem to find the code to display what category (custom taxonomy) a post belongs to in my template file. Something that is like the_category(', ') but for custom post type terms. Seems like it should be easy but I just can’t seem to get it.

Help is much appreciated!

2051 posts
  • Has been a member for 4-5 years
  • Bought between 50 and 99 items
  • Exclusive Author
  • United States
Landonw says
327 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 10 and 49 users
  • Sold between 50 000 and 100 000 dollars
  • United Kingdom
PaulWinslow says

I think the_terms() is what you’re looking for. Apologies if I’ve misread your post.

http://codex.wordpress.org/Function_Reference/the_terms

The the_terms() function is used to return a list of terms for a given taxonomy of a specific post.

You should be able to ignore the last 3 parameters, just passing the first 2 should be fine – the post’s ID and the name of your custom taxonomy.

Try this..

<?php the_terms( $post?>ID, 'taxonomy_name', '', '', '' ); ?>

edit – for some reason there’s a question mark showing up above, it’s supposed to be the following without spaces..

$ post – > ID

2051 posts
  • Has been a member for 4-5 years
  • Bought between 50 and 99 items
  • Exclusive Author
  • United States
Landonw says

@Paul: Oh! I see the difference. the_terms() displays it for you, but wp_get_post_terms() just returns the data.

206 posts
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 50 and 99 users
  • Sold between 50 000 and 100 000 dollars
  • United States
mlando says

Ah… I am so stupid sometimes… I kept putting the post type instead of the taxonomy in the args. Duh… no wonder. Took a post to clear my brain I guess. This community is awesome! thank you both.

by
by
by
by
by
by