Home › Forums › General Issues › Show number of posts with specific value within a category › Reply To: Show number of posts with specific value within a category
Sorry just re-read your question. You need to get the number of posts with a difficulty of Easy, Average & Difficult for each term right?
You’ll need a custom wp_query with a tax_query and a meta_query.. Something like the below will get you the post count for Easy Chocolate Deserts..
$args = array( 'post_type' => 'recipes', 'tax_query' => array( array( 'taxonomy' => 'desserts', 'field' => 'slug', 'terms' => 'chocolate', ), ), 'meta_query' => array( array( 'key' => 'difficulty', 'value' => 'Easy', 'compare' => 'IN', ), ), ); $easy_choc_query = new WP_Query( $args ); echo $easy_choc_query->found_posts;
More info from the Codex
To make it more dynamic we’d need to see your html structure. You’d possibly need to put something like the above inside the get_terms foreach loop, swapping out ‘chocolate’ and ‘easy’ for variables that changed with each iteration.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 29, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.