All of the real work here is being done by $geoDataStore->getPostIDsOfInRange
. That is where the search is done and that is what isn’t returning the results you want.
WP_Query
just pulls the specified post ID
s. There is no reason you should have to abandon that part of the code, though you may want to add 'orderby' => 'posts__in'
to preserve the order of the post ID
s passed into the query.
If $geoDataStore->getPostIDsOfInRange
is not returning all of the ID
s you want, you will have to look into how it works.
Now, this looks like the code that your $geoDataStore
class uses to make the query. There are no hooks in that you might be able to manipulate.
There are only two things I can think of doing.
- Extend that class and replace that function so that it searches your
meta information. - Or run another query to check your meta information and include the
places outside the generated radius– something like this.
In other words…
$posts = (array) $geoDataStore->getPostIDsOfInRange('place', $radius, $lat, $long);
$posts2 = new WP_Query(array(
// query for the others
'fields' => 'ids',
// other parameters
// Much like your original meta_query but
// I do think you need the 'OR' relationship
));
$posts = array_unique($posts + $posts2);
$args['post__in'] = $posts;
$places = new WP_Query($args);