WP Manifestindependent plugin directory
manifest / developer / mindshare-geo-query

WP Geo Query

Adds location search support to WP_Query, making it easy to create completely custom "Find Location" pages.

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/mindsharelabs/mindshare-geo-query/archive/refs/heads/master.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Example Usage

$query = new WP_Query(array(
    // ... include other query arguments as usual
    'geo_query' => array(
        'lat_field' => '_latitude',  // this is the name of the meta field storing latitude
        'lng_field' => '_longitude', // this is the name of the meta field storing longitude
        'latitude'  => 44.485261,    // this is the latitude of the point we are getting distance from
        'longitude' => -73.218952,   // this is the longitude of the point we are getting distance from
        'distance'  => 20,           // this is the maximum distance to search
        'units'     => 'miles'       // this supports options: miles, mi, kilometers, km
    ),
    'orderby' => 'distance', // this tells WP Query to sort by distance
    'order'   => 'ASC'
));