这可能是一个简单的问题,但我无法 grab 它 .
我在wordpress中有自定义帖子类型的WP_query列表,我需要为列表中的每个项目显示适当的分类(类别) .
我尝试使用谷歌搜索和搜索stackoverflow但是很短暂 .
此外,这是我用于显示特定帖子类型存在的所有分类标准:
function get_taxonomy_classes($theID) {
$post_type = get_post_type($theID);
$taxonomies = get_object_taxonomies($post_type, 'objects');
$terms = get_terms($taxonomies, array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => TRUE
));
foreach($terms as $term) {
echo $term->slug . " ";
}
}
还没有找到一种方法来使用上面的分类法这些术语:(
请帮帮忙,谢谢!
1 回答
没关系,伙计们 . 我自己找到了答案 .
这很简单,你只需要wp_get_object_terms()函数