Globals

Geo Controller automatically provides global access to geolocation data that you can use in your theme or plugin.

Access global object

<?php
global $CF_GEO;
echo $CF_GEO->city;
?>

Access global array

<?php
global $CFGEO;
echo $CFGEO['city'];
?>

Alternative: Load manually via class

If needed, you can create a new instance of the core class:

<?php
if ( class_exists('CF_Geoplugin') ) {
    $cfgeo = new CF_Geoplugin;
    $geo = $cfgeo->get();
    echo $geo->city;
}
?>

Use these globals anywhere in your WordPress project to access geolocation data like city, region, country, IP, and more.

Was this page helpful?