function.php

1、根据Tag的ID调用

//根据标签ID获取文章数
function get_tag_post_count_by_id( $tag_id ) {
   $tag = get_term_by( 'id', $tag_id, 'post_tag' );
  _make_cat_compat( $tag );
   return $tag->count;
}

2、根据Tag的名称调用

//根据标签别名获取文章数
function get_tag_post_count_by_slug( $tag_slug ) {
   $tag = get_term_by( 'slug', $tag_slug, 'post_tag' );
   _make_cat_compat( $tag );
  return $tag->count;
}

3、前台调用

<?php echo  get_tag_post_count_by_id( $tag_id ) ?>//根据Tag的ID调用
<?php echo  get_tag_post_count_by_id( $tag_slug ) ?>//根据Tag的名称调用

原文链接:http://www.511yj.com/wordpress-tag-count.html