206 posts
  • 7 Years of Membership
  • Affiliate Level 3
  • Author Level 6
  • Collector Level 3
+4 more
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!

2067 posts
  • Collector Level 3
  • 5 Years of Membership
  • Exclusive Author
  • United States
WilsonMade
says
381 posts Simple is the new black.
  • Weekly Top Seller
  • Elite Author
  • Author Level 7
  • 5 Years of Membership
+5 more
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

2067 posts
  • Collector Level 3
  • 5 Years of Membership
  • Exclusive Author
  • United States
WilsonMade
says

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

206 posts
  • 7 Years of Membership
  • Affiliate Level 3
  • Author Level 6
  • Collector Level 3
+4 more
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