Taxonomy List Based On Post ID

Share Now

Share on facebook
Share on pinterest
Share on twitter
Share on linkedin
Share on email
<?php $terms = get_the_terms( $main_post_id, 'category' ); ?>
<?php foreach( $terms as $term ): ?>
<a href="<?php echo get_term_link($term->slug, 'category'); ?>" class="catg-title"><?php echo $term->name; ?></a>
<?php endforeach; ?>

Or Just do this

<?php echo get_the_term_list( $main_post_id, 'category', '', ', ' ); ?>
Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert