I want to show a simple list of taxonomies associated with my CPT. The taxonomies are "skills". I have the following code:

            <?php $taxonomy = 'skill';
               $taxonomy_terms = get_terms($taxonomy);
               foreach ($taxonomy_terms as $term) {
               echo '~ '.$term->name .'<br />';
             } ?>

But it's spitting out ALL skills that are added to that CPT, not just the ones selected. I believe the taxonomy code is correct in the functions file because on my CPT listing in the dashboard, it shows the correctly selected skills associated with the corrosponding post. All help is greatly appreciated!

1 Answer 1


I found my own answer. Not sure why this different code works, but it does:

                $terms = wp_get_post_terms($post->ID, 'skill');
                $count = count($terms);
                if ( $count > 0 ) {
                foreach ( $terms as $term ) {
                echo '~ ' . $term->name . "<br /> ";
  • 1
    I think it is obvious why this code works ant the other not. This code is getting the post terms from the specified taxonomy assigned to the specified post ID. The first code is jus getting the terms from a taxonomy, not the terms assigned to a post. See the code for get_terms() and wp_get_post_terms() functions.
    – cybmeta
    May 5, 2014 at 21:29
  • @cybnet - thanks for clarifying that! makes perfect sense now. :) May 7, 2014 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.