A simple WordPress plugin for adding geographic data to posts.
For every post type selected on the plugin settings page. That type's add/edit screens will have an additional metabox automatically added. Metadata that is added to each record:
wp_gp_locationwp_gp_latitudewp_gp_longitudeMake a geo-aware query against the posts table. WP_GeoQuery accepts all arguments that WP_Query takes. latitude and longitude are optional parameters. If passed, distance is calculated and returned with each result. In addition to the regular fields, each result returns latitude, longitude, and location.
<?php
$query = new WP_GeoQuery(array(
'latitude' => '37.5160', // User's Latitude (optional)
'longitude' => '-77.5005', // User's Longitude (optional)
'posts_per_page' => 25, // Any regular options available via WP_Query
));
foreach($query->posts as $post)
{
echo " {$post->post_title}<br />\n";
// returned only if latitude and longitude are passed into WP_GeoQuery
echo " {$post->distance}<br />\n";
// Always returned by WP_GeoQuery
echo " {$post->location}<br />\n";
echo " {$post->latitude}<br />\n";
echo " {$post->longitude}<br />\n";
echo "<br />\n";
}
?>
Requires: 3.0 or higher
Compatible up to: 3.4.2
Last Updated: 2012-8-20
Downloads: 409
Got something to say? Need help?