Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialcsj
12,678 PointsDisplay custom taxonomy on a page
Sorry this is simple stupid question, but I can't get it to work. There must be some logical part I'm missing.
Using Custom Post Type UI.
- I've create a custom post type, called
team
. - I've create a custom taxonomy
jobtitle
and attached it toteam
. And it shows up and I can add to it. - I've created a page named
single-team.php
put display the post types content. And it works. - But how do I display the current taxonomy associated with each post. It could be
manager
oradministration
.
I've tired the codex and have come across get_the_terms but clearly I'm doing it way wrong.
get_the_terms( $post->ID, 'jobtitle' );
But I even can see that it lacks something.
I don't want to display the whole list of taxonomies ( for now) just the one or two that might be associated with a spectic team member (post).
Hope it make sense.
Doru Marginean
2,290 PointsDoru Marginean
2,290 PointsHi Christian Steen Jørgensen,
The example you provided using get_the_terms() returns an object and you need to construct the HTML. I think it will be easier for you to use get_the_term_list().
More info here: https://codex.wordpress.org/Function_Reference/get_the_term_list