Use the code below:
$taxonomy = "category"; // can be category, post_tag, or custom taxonomy name// Using Term Slug$term_slug = 'some-category';$term = get_term_by('slug', $term_slug, $taxonomy);// Fetch the countecho $term->count;
See here.