Workaround for anyone experiencing the same problem: hook to the ‘acf/save_post’ action and use update_post_meta() to duplicate the latitude and longitude data to hidden meta fields, enabling a custom query to be crafted to return posts by distance:
`function location_search($latitude, $longitude, $maxdistance = 5) {
global $wpdb;
$query = “SELECT wp_posts.post_title as post_title,
wp_posts.ID as post_id,
latitude.meta_value as latitude,
longitude.meta_value as longitude,
( 3959 * acos(
cos( radians( $latitude ) ) *
cos( radians( CONVERT( latitude.meta_value, DECIMAL( 10, 6 ) ) ) ) *
cos( radians( CONVERT( longitude.meta_value, DECIMAL( 10, 6 ) ) ) – radians( $longitude ) ) +
sin( radians( $latitude ) ) * sin( radians( CONVERT( latitude.meta_value, DECIMAL( 10, 6 ) ) ) )
) ) AS distance
FROM wp_postmeta as latitude, wp_postmeta as longitude,
wp_posts
WHERE (wp_posts.ID = latitude.post_id
AND latitude.meta_key = ‘_latitude’ )
AND (wp_posts.ID = longitude.post_id
AND longitude.meta_key = ‘_longitude’ )
HAVING distance < $maxdistance
ORDER BY distance ASC”;
return $query;
}`