// Get the category ID from url
$catsearched = $_GET['product_cat'];
//printf($catsearched);
$earth_radius = 6371;
// Get products of category with in range distance
$querystrShop = $wpdb->prepare("
SELECT productid
AS post_id,(%d * ACOS(COS(RADIANS(%s)) * COS(RADIANS(phiz_geo_location.latitude)) * COS(RADIANS(phiz_geo_location.longitude) - RADIANS(%s)) + SIN(RADIANS(%s)) * SIN(RADIANS(phiz_geo_location.latitude))))
AS distance, phiz_postmeta.meta_value
FROM phiz_geo_location
JOIN phiz_term_relationships ON phiz_geo_location.productid = phiz_term_relationships.object_id
LEFT JOIN phiz_postmeta ON phiz_geo_location.productid = phiz_postmeta.post_id
LEFT JOIN phiz_posts AS p ON phiz_postmeta.post_id = p.id
WHERE phiz_term_relationships.term_taxonomy_id IN ($catsearched)
AND p.post_title="".$html.""
AND p.post_status="publish"
GROUP BY post_id
HAVING distance < %f",
$earth_radius,
$latitude,
$longitude,
$latitude,
$radius
);
$sql = $wpdb->get_results( $querystrShop );
$sameCIParrayOfID = wp_list_pluck( $sql, 'post_id' );