Support

Account

Home Forums General Issues Count completed custom post types by a particular field. Reply To: Count completed custom post types by a particular field.

  • Do a query something like this

    
    $args = array(
      'post_type' => 'your-post-type',
      'post_per_page' => -1, // get them all
      'post_status' => 'publish', // or whatever status your looking for
      'meta_query' => array(
        array(
          'key' => 'your-field-name'
          'compare' => 'EXISTS',
        )
      )
    )
    $query = new WP_Query($args);
    $post_count = count($query->posts);