1. Using WordPress Shortcodes in PHP
The simplest method is to execute a Geo Controller shortcode using the native WordPress do_shortcode() function.
For example, display the visitor’s detected city:
echo esc_html(
do_shortcode('[cfgeo return="city"]')
);
Retrieve the visitor’s country:
echo esc_html(
do_shortcode('[cfgeo return="country"]')
);
Or retrieve the country code:
echo esc_html(
do_shortcode('[cfgeo return="country_code"]')
);
This method is useful when you already use Geo Controller shortcodes throughout your website and want to reuse them inside PHP templates.
Note: Shortcodes must be registered before calling do_shortcode(). Execute these examples during normal WordPress rendering, after the plugins have initialized.
- Globals
- Constants
- Filters
- Utilities
- Security Notes
- HTTP Codes Helper
- Get Current User (ID or Email)
- Quick Access to Geo Fields
- Location Checks (City/Region/Country/Postcode)
- Safe Redirect (Preserving Parameters)
- Cache Invalidation (Global + Popular Cache Plugins)
- Bot/Crawler Detection
- HTTP Requests with Caching (GET/POST)
- Request Sanitizers (GET/POST)
- URL/Host Helpers
- Fragment Caching (W3TC mfunc)
- Defender Cookie (Anti-Abuse Signal)
- Display Flag
- Check if REST is Enabled
- Miscellaneous Utilities
