我的Wordpress中有一个带有类别的自定义post_type。如何在模板中显示类别名称?
答案 0 :(得分:1)
the_category();
或者,如果您要列出帖子的类别,请用逗号分隔:
the_category(', ');
codex是你的朋友 - http://codex.wordpress.org/Function_Reference/the_category
答案 1 :(得分:1)
//Returns All Term Items for "my_taxonomy"
$term_list = wp_get_post_terms($post->ID, 'my_taxonomy', array("fields" => "all"));
print_r($term_list);
Array
(
[0] => WP_Term Object
(
[term_id] => 145
[name] => Example Category
[slug] => example-cat
[term_group] => 0
[term_taxonomy_id] => 145
[taxonomy] => adcpt_categories
[description] =>
[parent] => 0
[count] => 2
[filter] => raw
)
)