How to show only tagged CPT categories / taxonomies for a custom post type?

I am using this code and its echoing all the taxonomies available for the particular CPT. I am calling this in a single-posttype.php to show taxonomies. What i need is to display only the taxonomies tagged to the current post-type instead of displaying all the taxonomies available. Please help.

        <?php

        $taxonomy = 'map_feature';
        $terms = get_terms($taxonomy);

        if ( $terms && !is_wp_error( $terms ) ) :
        ?>
        <ul>
        <?php foreach ( $terms as $term ) { ?>
        <li><a href="<?php echo get_term_link($term->slug, $taxonomy); ?>">
        <?php echo $term->name; ?></a></li>
        <?php } ?>
        </ul>
        <?php endif;?>

Read more here: How to show only tagged CPT categories / taxonomies for a custom post type?

Leave a Reply

Your email address will not be published. Required fields are marked *