wp_count_terms() counts the number of terms in a taxonomy but not the number of post that have those terms and I've found that wp_count_post() does not accept a taxonomy.

So whats a guy gotta do to count the number of post in a taxonomy term?


Term: Apples Post: 89 (this is what I want to get, the number of post with the 'Apples' taxonomy)



The function you are looking for is get_term() http://codex.wordpress.org/Function_Reference/get_term

and the code would look something like this:

$term = get_term( 1, 'category' );//for example uncategorized category
echo 'count: '. $term->count;
  • 1
    Does this count deleted posts as well ? – divyenduz Sep 22 '16 at 8:30
  • will count only published posts, which might or might not be enough – Mark Kaplun Sep 28 '17 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.