To avoid the waste of resources we cache the user geolocation once it’s generated. That means that if you change your location using a VPN you will still see the first location you used to visit the site unless you enable debug mode which it’s used to test the plugin. You have two options for debugging;
Debug mode
You can simple turn on debug mode in the settings page of the plugin.
Once you do that you can use any VPN software like “Hola Internet” to change your location or by manually changing your IP using the following php filter:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Geotargeting Plugin. https://wordpress.org/plugins/geotargeting/ | |
* Filter IP if you are for example in local host | |
*/ | |
add_filter( 'geot/user_ip', 'geot_ip'); | |
function geot_ip( $ip ) { | |
return '192.192.192.192'; | |
} |
Query string parameters
You can pass some query strings to your site url in order to see the page as if you were from certain country
- geot_debug : Accepts country ISO CODE . It’s required for all the query string debug options eg: domain.com/?geot_debug=US
- geot_state : Accepts State names. Eg: domain.com/?geot_debug=US&geot_state=Florida
- geot_state_code : State iso code. Eg: domain.com/?geot_debug=US&geot_state=Florida&geot_state_code=FL
- geot_city : City name. Eg: domain.com/?geot_debug=US&geot_state=Florida&geot_state_code=FL&geot_city=Miami
- geot_zip: Eg: domain.com/?geot_debug=US&geot_state=Florida&geot_state_code=FL&geot_city=Miami&geot_zip=33166
Creating a debug page
Also it’s a good practice to include some shortcodes on a test page to be sure that is resolving correctly. For example you can paste this into a normal wordpress page:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List of available shortcodes to Paste on a demo page | |
[[geot_country_code]]: [geot_country_code] | |
[[geot_country_name]]: [geot_country_name] | |
[[geot_city_name]]: [geot_city_name] | |
[[geot_state_name]] : [geot_state_name] | |
[[geot_state_code]]: [geot_state_code] | |
[[geot_zip]]: [geot_zip] |