Sunday, May 14, 2017

How to get the taxonomy values of a custom post type

If we want to fetch the taxonomy term of a specific post then we could do that.

$terms = get_the_terms( $post->ID, 'publication_category' );
if ($terms) {
    foreach($terms as $term) {
      echo $term->name;

in this function 
$post->ID :- Your post id. 
 'publication_category'  - its a taxonomy name.

No comments:

Post a Comment