How to get the taxonomy values of a custom post type

前端 未结 4 1885
清歌不尽
清歌不尽 2021-02-05 22:44

I am creating a new template that will get all the custom post type (Case Studies) content, including the taxonomies values associated with it.

So far I got the follow

4条回答
  •  一生所求
    2021-02-05 23:16

    assume: I register a taxonomy with custom post type name publication_category.

    On your custom post type template write :

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

提交回复
热议问题