$what_is_my_ip = $_SERVER['REMOTE_ADDR'];
echo var_export( unserialize( file_get_contents( 'http://www.geoplugin.net/php.gp?ip = '.$_SERVER['REMOTE_ADDR'] ) ) );
array (
'geoplugin_request' => '182.75.235.222',
'geoplugin_status' => 206,
'geoplugin_credit' => 'Some of the returned data includes GeoLite data created by MaxMind, available from http://www.maxmind.com.',
'geoplugin_city' => '',
'geoplugin_region' => '',
'geoplugin_areaCode' => '0',
'geoplugin_dmaCode' => '0',
'geoplugin_countryCode' => 'IN',
'geoplugin_countryName' => 'India',
'geoplugin_continentCode' => 'AS',
'geoplugin_latitude' => '20',
'geoplugin_longitude' => '77',
'geoplugin_regionCode' => '',
'geoplugin_regionName' => '',
'geoplugin_currencyCode' => 'INR',
'geoplugin_currencySymbol' => '₨',
'geoplugin_currencySymbol_UTF8' => '₨',
'geoplugin_currencyConverter' => '67.8358',
)
function getLocationInfoByIp($ip_addr)
{
$return_data = array('country'=>'', 'city'=>'');
$ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip_addr));
if($ip_data && $ip_data->geoplugin_countryName != null)
{
$ret = $ip_data->geoplugin_countryName;
if($ip_data->geoplugin_city != null){
$ret .= ', '.$ip_data->geoplugin_city;
}
return $ret;
}
}
$loc=getLocationInfoByIp($_SERVER['REMOTE_ADDR']);
In this tutorial, I have write code to add custom meta query in main query…
This website uses cookies.