This is potentially a duplicate but what was listed on the following link didn't work for me : Return only Count from a wp_query request?
I can't get the count using the query below. If I set
posts_per_page = -1 it renders a blank page, if I set it to something like 10, it returns 10 found_posts..
There's 190k results with "special_key", so maybe something to do with it..?
// There are 190k records with post_meta "special_key" on each coupon/post. $query = array( 'post_type' => 'shop_coupon', 'meta_key' => 'special_key', 'fields' => 'ids', 'no_found_rows' => true, ); $results = new WP_Query($query); echo $results->found_posts; //// This is 0... echo $results->count_posts; //// This is 0... wp_reset_postdata();
If it helps, I'm running the query from inside a plugin.