像这样的东西应该可以工作(我已经在自定义模板文件中测试了它)。
<?php $terms = get_terms("name_of_your_custom_taxonomy");
foreach($terms as $term)
{
echo $term->slug; // you can display term name, description ..... Look at codex to see the parameters
$items = get_posts( array(
\'post_type\' => \'name_of_your_custom_post_type)\',
\'numberposts\' => -1,
\'taxonomy\' => \'name_of_your_custom_taxonomy\',
\'term\' => $term->slug
) );
$count = count( $items );
echo $count;
}
?>