How to show amount of post in a taxonomy with advanced custom fields?

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?

Topic advanced-custom-fields advanced-taxonomy-queries taxonomy Wordpress

Category Web


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;

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.