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!
Check out the above
the_terms() is what you’re looking for. Apologies if I’ve misread your post.
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.
<?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
@Paul: Oh! I see the difference. the_terms() displays it for you, but wp_get_post_terms() just returns the data.
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.