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
You can use get_terms, then term->count..
The below will list all the terms from the Desserts taxonomy with their name and post count.
<?php
$terms = get_terms( 'desserts' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
echo '<ul>';
foreach ( $terms as $term ) {
echo '<li>' . $term->name . ' - ' . $term->count . '</li>';
}
echo '</ul>';
}
?>
For more info check – HERE
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.