我在我的 Wordpress 中有一个自定义的 post_type,带有类别。如何在模板中显示类别名称?
问问题
808 次
2 回答
1
the_category();
或者,如果您想列出帖子的类别,请以逗号分隔:
the_category(', ');
codex 是你的朋友 - http://codex.wordpress.org/Function_Reference/the_category
于 2012-07-22T13:49:35.213 回答
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
)
)
于 2018-04-12T06:09:03.500 回答