Post queries by latitude and longitude

I am struggling with getting post queries by coordinates. I have meta fields map_lat and map_lng for almost all post types. I am trying to return posts from one custom post type (“beaches” in this example): function get_nearby_locations($lat, $long, $distance){ global $wpdb; $nearbyLocations = $wpdb->get_results( “SELECT DISTINCT map_lat.post_id, map_lat.meta_key, map_lat.meta_value as locLat, map_lng.meta_value as locLong, … Read more

Create multiple Search functions for posts / custom post types and everything

I’m currently working on a search function in a wp site. The plan is to have a search function on the news page which just searches posts. I’m achieving this by adding the below to my functions.php file: /* search just posts */ function SearchFilter($query) { if ($query->is_search) { $query->set(‘post_type’, ‘post’); } return $query; } … Read more

I have geocoded posts with latitude longitude – How to search by radius?

I have posts which are geocoded with latitude and longitude from Google. I basically can enter an address in a post custom field and the latitude and longitude are placed into two separate meta fields. I’d like to create a custom search letting visitors search their zip/postal code and find the nearest locations. I’ve found … Read more

Optimizing a Proximity-based Store Location Search on a Shared Web Host?

I’ve got a project where I need to build a store locator for a client. I’m using a custom post type “restaurant-location” and I have written the code to geocode the addresses stored in postmeta using the Google Geocoding API (heres the link that geocodes the US White House in JSON and I’ve stored the … Read more