Home Forums ACF PRO How many fields are filled to output in frontend


How many fields are filled to output in frontend

  • In wordpress, you can calculate and output how many records are contained in a certain category. But I have a “download” field in each entry. How do I calculate the total number of filled fields in all records and output this figure to the frontend?

    Example for post

    function tp_catpostcount($atts) {
    "id" => ''
    ), $atts));
    $post_count = get_category($id)->category_count;
    $cat_name = get_category($id)->name;
    $cat_slug = get_category($id)->slug;
    return ''.$post_count.'';
    add_shortcode('cpc', 'tp_catpostcount');
  • There isn’t any way to do this in WP directly. You would need to do a WP_Term_Query that includes a meta_query looking for your field name that is not an empty value.

  • I am far from programming. Can you show an example? Thanks.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.