Post count by meta_key meta_value [closed]
// retrieve all meta_values with key ‘state’ from database $state_posts = $wpdb->get_results(” SELECT meta_value FROM “. $wpdb->prefix.”postmeta WHERE meta_key = ‘state’ ORDER BY meta_value ASC”, ARRAY_A ); // define counting array $state_count = array(); // iterate through meta_values, count the occurence of each state foreach ( $state_posts as $state_post ) { if ( isset ( … Read more