I have 294 queries on my wordpress site. I checked using sql monitorand the maximum queries are to display count of a cities list custom field. Lets say there are 200 cities then 200 queries are happening in a loop to count the number of posts about a city. Is a there a way to do this more efficiently.
The code I have used to get counts of countries is
<?php
global $wpdb;
$countries = tgt_get_countries();
foreach ($countries as $country) {
$testcount = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_value = '$country' AND meta_key = 'tgt_job_country'");
if ($testcount !=0)
echo "<li><a href='http://dsdjjhfgd.net/s=jobseeker&usertype=jobseeker&country=".$country."&search=Search'>".$country."(".$testcount.")</a></li>";
}
?>