Issue with geolocate shortcode
-
Hello,
Today I wanted to add a new function to my website, for displaying the guest country name with a shortcode. Code is bellow. It doesn’t work with your plugin enabled, I tested it all. How to fix this issue? Rank math doesn’t need to block this, it’s strange.
// Define shortcode function to display country name function get_client_country_name() { // Get the country code of the client using WooCommerce geolocation function $country_code = WC_Geolocation::geolocate_ip()['country']; // Get the country name based on the country code $country_name = WC()->countries->countries[ $country_code ]; // Return the country name return $country_name; } // Register shortcode to use the function add_shortcode( 'client_country_name', 'get_client_country_name' );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Issue with geolocate shortcode’ is closed to new replies.