只需要兩步就可以實現根據wordpress指定ID標簽獲取該tag下的文章數量
第一步:把下面的代碼放到functions.php文件中
//Put the following code into the functions.php file wodepress.com
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;
}
第二步:在需要的位置調用以下的代碼
//Call the following code at the desired location wodepress.com
<?php echo get_tag_post_count_by_id( $tag_id ) ?>