最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

custom post types - How do i get the taxonomy term name on the CPT archive page?

programmeradmin2浏览0评论

In archive-news.php, i've tried

global $wp_query;

$tax = $wp_query->get_queried_object();
echo $tax->name;

But this gets the taxonomy, not the taxonomy term.

I need to print the tax term name for each entry on the archive page which lists posts in the custom post type.

In archive-news.php, i've tried

global $wp_query;

$tax = $wp_query->get_queried_object();
echo $tax->name;

But this gets the taxonomy, not the taxonomy term.

I need to print the tax term name for each entry on the archive page which lists posts in the custom post type.

Share Improve this question asked Jun 16, 2020 at 7:08 Brad DaltonBrad Dalton 6,9652 gold badges36 silver badges47 bronze badges
Add a comment  | 

1 Answer 1

Reset to default -1

wp_get_post_terms did the trick

发布评论

评论列表(0)

  1. 暂无评论