Wordpress 在WP循环中显示某个帖子的所有分类法

Wordpress 在WP循环中显示某个帖子的所有分类法,wordpress,taxonomy,custom-post-type,Wordpress,Taxonomy,Custom Post Type,这可能是一个简单的问题,但我就是想不通 我在wordpress中有一个自定义帖子类型的WP_查询列表,我需要为列表中的每一项显示适当的分类法(类别) 我试着用谷歌搜索stackoverflow,但没有找到 此外,这也是我用来显示某个帖子类型的所有分类法段塞的原因: function get_taxonomy_classes($theID) { $post_type = get_post_type($theID); $taxonomies = get_objec

这可能是一个简单的问题,但我就是想不通

我在wordpress中有一个自定义帖子类型的WP_查询列表,我需要为列表中的每一项显示适当的分类法(类别)

我试着用谷歌搜索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 . " ";
        }

    }
仍然没有找到将这些术语用于上述分类法的方法:(


请帮忙,谢谢!

别客气,伙计们。我自己找到了答案

它非常简单,只需要wp_get_object_terms()函数

   $termss = wp_get_object_terms(get_the_ID(), 'portfolio_category');
   foreach ($termss as $term) {
      echo $term->slug;
   }