Hi!
I want to get the number of posts in a given ACF category.
Until now, I was using the following function to create a shortcode for WordPress native categories:
// Add Shortcode to show posts count inside a category
function category_post_count( $atts ) {
$atts = shortcode_atts( array(
'category' => null
), $atts );
// get the category by slug.
$term = get_term_by( 'slug', $atts['category'], 'category');
return ( isset( $term->count ) ) ? $term->count : 0;
}
add_shortcode( 'category_post_count', 'category_post_count' );
Is there anything similar that could be done with ACF?
Is there anyone with a solution on this?