List Taxonomy Terms specific to a Post
-
I’ve got a Custom Post type called “People.” I’ve created a Taxonomy called “Specialties” that is set up hierarchically, such that its terms appear functionally as do Categories. So, when I create a new Person, the various specialties appear in the Edit Post screen and I can easily select what specialties each person has.
In the template for this taxonomy, I’d like to show each person’s entry with a list of the specialties they possess as a link to that taxonomy term’s archive page. This functionality is identical to the functionality in the_category(), but I cannot seem to replicate it.
Here’s what I have so far:
<?php $terms = get_terms("specialties"); $count = count($terms); if ( $count > 0 ){ echo "<ul>"; foreach ( $terms as $term ) { echo '<li><a href="'.get_term_link($term->slug, 'specialties').'">'. $term->name . "</a></li>"; } echo "</ul>"; }?>
This, however, will output a linked list of ALL taxonomy terms regardless of whether this Person is associated with them.
Any help would be appreciated.
- The topic ‘List Taxonomy Terms specific to a Post’ is closed to new replies.