Geo Query
WordPress plugin: Geo Query - Modify the WP_Query/WP_User_Query to support the geo_query parameter. Uses the Haversine SQL implementation by Ollie Jones. With a Rest API example and support for an existing custom table .
by Birgir Erlendsson (birgire) · github.com/birgire/geo-query · website
★ 68stars
3kcomposer installs
13forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/birgire/geo-query/archive/refs/heads/master.zipAlso on Packagist as birgir/geo-query:
composer require birgir/geo-queryDeclares an update source (https://github.com/birgire/geo-query.git), so updates arrive through the plugin's own updater.
From the readme
WordPress plugin: Geo Query
Description
This plugin adds a support for the geoquery part of the WPQuery and WPUserQuery.
Supports geo data stored in post/user meta or in a custom table.
It uses the Haversine SQL implementation by Ollie Jones (see here).
The plugin works on PHP 5.3+.
It supports the GitHub Updater.
Activate the plugin and you can use the geoquery parameter in all your WPQuery and WPUserQuery queries.
Few examples are here below, e.g. for the Rest API.
Installation
Upload the plugin to the plugin folder and activate it.
To install dependencies with Composer (not required):
composer install
or
php composer.phar install
within our folder. See here for more information on how to install Composer.
Then play with the example below, in your theme or in a plugin.
Have fun ;-)
Example - Basic WPQuery usage:
Here's an example of the default input parameters of the geoquery part:
$args = [
'posttype' = 'post',
'postsperpage' = 10,
'ignorestickyposts' = true,
'orderby' = [ 'title' = 'DESC' ],
'geoquery' = [
'lat' = 64,