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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.