How to get the taxonomy values of a custom post type

前端 未结 4 1894
清歌不尽
清歌不尽 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:34

    Check this function: wp_get_post_terms()

    Assuming your custom post type Case Study supports two taxonomies called country and subject, you can try something like this:

    post->ID, array( 'country', 'subject' ) ); ?>
    
    

    taxonomy; ?>: name; ?>

    Your output would be something like:

    Country: United Kingdom
    Subject: Biology
    Subject: Chemistry
    Subject: Neurology
    

提交回复
热议问题