📜  获取分类法 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:07.505000             🧑  作者: Mango

代码示例2
$index_query = new WP_Query(array('post_type' => 'company', 'posts_per_page' => '-1', 'order' => 'DESC'));

while ($index_query->have_posts()) : $index_query->the_post();

    $taxonomy_ar = get_the_terms($post->ID, 'tax-name');

    $output = '';
    foreach($taxonomy_ar as $taxonomy_term) {
        $output .= ''.$taxonomy_term->name.' '.$taxonomy_term->count.' ';
    }
    $output .= '';

    echo $output;

endwhile;​