我如何获得自定义帖子类型分类描述?我的帖子类型是'发布' 和分类法是' release_category' ,我应该使用什么代码?
答案 0 :(得分:3)
如果您已经拥有term_id
term_description($ term_id,$ taxonomy):https://codex.wordpress.org/Function_Reference/term_description
term_description($term_id, 'release_category');
如果您只知道帖子ID
首先,您必须使用wp_get_post_terms($ post_id,$ taxonomy,$ args)获取后分类:https://codex.wordpress.org/Function_Reference/wp_get_post_terms
$taxonomies = wp_get_post_terms(get_the_ID(), 'release_category', array('fields' => 'all'));
foreach($taxonomies as $taxonomy) {
echo $taxonomy->description;
}