birgire / 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 .

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

404 Error in get_pre_posts Callback

brainsyke opened this issue · comments

I am getting 404 error. How do i get this to work correctly? Am I doing something incorrect? See images attached for details. please Help!!

function filter_queryby_currentcity( $query ) {
if ( !is_admin() )
{
getGeoipDetails();
//print_r("filter:".trim(getGeoipDetails()["city"]));
// print_r("IP Based geo details".microtime(true).":".$GLOBALS['location_details']['geolat']);

$query->set( 'geo_query', [
  'lat'                =>  $GLOBALS['location_details']['geolat'],                                // Latitude point
    'lng'                =>  $GLOBALS['location_details']['geolong'],                               // Longitude point
   'lat_meta_key'       =>  '_tmbu_lat',                         // Meta-key for the latitude data
   'lng_meta_key'       =>  '_tmbu_lng',                         // Meta-key for the longitude data 
   'radius'             =>  50,                               // Find locations within a given radius (km)
   'order'              =>  'DESC',                            // Order by distance
   'distance_unit'      =>  111.045,                           // Default distance unit (km per degree). Use 69.0 for statute miles per degree.
   'context'            => '\\Birgir\\Geo\\GeoQueryHaversine' // Default implementation, you can use your own here instead.

post_meta_tabe
print_rquery
]);

Thanks for the ticket @brainsyke

I will try to look at it when I have some more time in the next few days.

I am trying to modify the default search query using pre_get_posts . However , it is not working ! Please help