Hi @senorpedo,
You can add meta query as per your requirements. Order by meta key some time not works in wordpress. You need to test several things to work some time it will works.
function get_default_events_by_user_location($query_args,$args)
{
if ( empty( $args['search_location'] ) )
{
$ip = $_SERVER['REMOTE_ADDR'];
//$details = unserialize(file_get_contents("https://www.geoplugin.net/php.gp?ip={$ip}"));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.geoplugin.net/json.gp?ip=" . $ip);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response= curl_exec($ch);
$details=json_decode($response, true);
curl_close($ch);
$country = $details["geoplugin_countryName"];
$city = $details["geoplugin_city"];
$location_meta_keys = array( 'geolocation_formatted_address', '_event_location', 'geolocation_state_long','geolocation_country_long' );
$location_search = array( 'relation' => 'OR' );
foreach ( $location_meta_keys as $meta_key ) {
$location_search[] = array(
'key' => $meta_key,
'value' => $country ,
'compare' => 'like'
);
}
$query_args['meta_query'][] = $location_search;
return $query_args;
}
else
{
return $query_args;
}
}
//filter for default location wise events
add_filter('get_event_listings_query_args','get_default_events_by_user_location',10,2);
In above example we have assign event which is inside perticular location.
You can also try [events show_pagination="true" orderby="_event_start_date"]
Let me know if it works.
Thank you