Count number of post in Taxonomy?

by Jon Furry   Last Updated September 11, 2019 13:08 PM

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?

Example:

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

Thanks!



Answers 2


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;
Madalin.Ungureanu
Madalin.Ungureanu
December 16, 2013 21:02 PM

Estoy probando de mostrar el numero de taxonomia, pero no numero total de taxonomia que tengo aqui, sino el numero (count) de cada una de las entradas con dicha categoria.

he visto que usando wp_count_terms puedo saber el numero TOTAL de entradas que tiene dicha taxonomia, pero no me saca el numero que tiene cada una de ellas.

Cheff
Cheff
September 11, 2019 12:55 PM

Related Questions



Count Number of Posts in Taxonomy Term in Last 24 Hours

Updated September 02, 2018 13:08 PM



Specific post type count of taxanomy archive page

Updated June 21, 2019 13:08 PM