I have places stored as posts in WP's posts table.
I am doing some geo-locating using Geo Data Store (http://wordpress.org/plugins/geo-data-store/). This is working great for me, as I can currently get results from any radius I choose from a starting point (a city converted to coordinates).
I was previously using an exact match on the city - when a user clicked a city, it loaded results with posts that held postmeta exactly matching the clicked city - I click Asheville, I get places in Asheville.
The problem that switching to geo-location has caused is that now when a user clicks a city, some results within that city aren't shown because they are not within the given radius of the city center, even though the city postmeta exactly matches the clicked city.
The relevant part of my query looks like this:
$coordinates = ConvertCityStateToCoords($city.', '.$state);
$lat = (double)$coordinates['lat'];
$long = (double)$coordinates['long'];
$posts = (array) $geoDataStore->getPostIDsOfInRange('place', $radius, $lat, $long);
$posts = array_map('intval',$posts);
$args['post__in']=$posts;
$places= new WP_Query($args);
Whereas it used to look like this:
$args['meta_query'][] = array(
'key' => 'place_state',
'value' => $state,
);
$args['meta_query'][] = array(
'key' => 'place_city',
'value' => $city
);
$places= new WP_Query( $args );
My question is this: will I have to abandon WP_Query (which I would rather not do because I am also using it for pagination and ordering) in favor of SQL that will allow me to query an 'optional' field - SQL that would include posts within the radius as well as posts with the exact match city, but not exclusively one or the other.