I am trying to display the post count of some taxonomies. I have a custom template that I am showing some taxonomies on. I am using advanced custom fields to assign each repeater field to a taxonomy. How can I display the amount of post for each one?
You can use this code for getting number of posts in a taxonomy:
$args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => -1, 'tax_query' => array( array( 'taxonomy' => 'your-taxonomy-name', 'field' => 'slug', 'terms' => 'some-slug', ) ) ); $query = new WP_Query( $args ); echo $query->post_count;