WP_Query count of different meta key values [duplicate]
Just loop over the posts and bump the count based on the value of ads_class: $ads_1 = $ads_2 = $ads_3 = 0; while ( $ads->have_post() ) { $ads->the_post(); switch ( ( int ) get_post()->ads_class ) { case 1 : $ads_1++; break; case 2 : $ads_2++; break; case 3 : $ads_3++; break; } } $ads_1; // … Read more