It should work.
Are you using shortcodes or PHP syntax? What does the function return?
if (function_exists('geoip_detect2_get_info_from_current_ip')){
$userInfo = geoip_detect2_get_info_from_current_ip();
$countryCode = $userInfo->country->isoCode;
}
This code is in the header.php. Doesn’t even enter the if block. Without the if block we get error – function doesn’t exist.
The weird thing is that it works on any other page.
This is before plugins_loaded then. Try to wrap it in
add_action(‘plugins_loaded’, function() { … });
(What do you want to add in the header.php? Maybe body class is a possibility for you?)
Hello again Benjamin,
Turns out we are using Plugin Organizer and for some reason the Geo IP Detection plugin was turned off for the home page. That’s why the home page wasn’t recognizing the geoip_detect2_get_info_from_current_ip.
So it’s fixed now. Thank you for the quick support.