I am having two meta keys, longitude and latitude, and what I am trying to do is the equivalent of the google store location algorithm for distance, in wp_query:
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;
What I am trying to do, is get a list of custom post types (stores) that contain long/lat (custom fields), and having an x distance (it's for a store locator, like google's example).
I have already done it with $wpdb way, but I am looking for a wp_query because I want the paging and the extra filtering by using/removing an add_filter() directive to the page. Is it possible to execute such complex query, or should I stick to $wpdb method?