I've been struggling with this for the last few days and just keep seem to get it right. Here's the situation:
I have a provider directory (hospitals) in a custom post type. The 2,000+ providers were imported via CSV with location data, for which I then used the geomashup plugin to add coordinates as meta info. So all the posts have the necessary components to getting this done.
Now what I need to do is build a search for on the frontpage that lets the user enter a zip code or city (text box), select a radius (in miles, from a dropdown list), and (optionality) a specialty (which is stored in a custom taxonomy).
I've messed with a loop based on the query info in the geomashup docs, but to no avail. I've been plugging in specific lat/long coordinates which should return results, yet nothing shows up.
Here's the query code I've been using:
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $rq = new WP_Query( array( 'posts_per_page' => 9999, 'paged' => $paged, 'geo_mashup_query' => array( 'near_lat' => 26.055, 'near_lng' => -80.153, 'radius_mi' => 50, ), ) ); while ($rq->have_posts()) : $rq->the_post(); ?>
Ultimately, I need help figuring out how to configure the search form on the homepage, pass the variables to the search results page, and get results to show up. There are various "find nearby" plugins and answers here related to radius searches, but there are simply too many of these items and they needed to belong in a CPT w/ custom taxonomy and not be plugin based.