因为你已经通过了”category“在”get_terms_by()“”函数作为第三个参数。
请更换“add_custom_taxonomy_here“使用下面代码中的自定义分类法slug。
// Add Shortcode to show posts count inside a category
function category_post_count( $atts ) {
$atts = shortcode_atts( array(
\'category\' => null
), $atts );
// get the category by slug.
$term = get_term_by( \'slug\', $atts[\'category\'], \'add_custom_taxonomy_here\');
return ( isset( $term->count ) ) ? $term->count : 0;
}
add_shortcode( \'category_post_count\', \'category_post_count\' );