WP:如何获得所有分类法';特定自定义类型的名称


WP: how to get all taxonomies' name of a spcific custom type

我正在尝试获取特定自定义类型的所有分类名称
在stackoverflow档案中,我找到了下面一个postID的脚本。我想循环单个自定义帖子类型的所有分类名称,而不仅仅是一个id。
分类应为:my_tax,自定义帖子类型:my_team

            $terms = get_the_terms( $post->ID, 'my_tax' );
            foreach($terms as $term) {
                echo $term->name;
            }

这样的代码可以是:

$type = 'my_team';
$args = array(
  'post_type' => $type,
  'post_status' => 'publish',
  'posts_per_page' => -1,
);
$my_query = null;
$my_query = new WP_Query($args);
if ($my_query->have_posts()) {
    while ($my_query->have_posts()) {
        $post = $my_query->the_post();
        $terms = get_the_terms( $post->ID, 'my_tax' );
        foreach($terms as $term) {
            echo $term->name;
        }
    }
}
wp_reset_query();  // Restore global post data stomped by the_post().