You need to add the option “Resolve shortcodes via AJAX”
Hi there,
As mentioned above I tried pretty much all settings including AJAX. To confirm I have just tried using ajax to resolve shortcodes and add classes, it does not work period. Same thing with adding classes without using ajax, no errors no nothing.
we are using:
HostIP.info Web-API
Add a country-specific CSS class to the <body>-Tag on every page.
Disable caching a page that contains a shortcode or API call to geo-dependent functions.
At least WP SuperCache, W3TotalCache and ZenCache are supported.
Enable AJAX endpoint to get the information for the current IP even on cached pages.
Add JS Helper functions to all pages.
This enables you code geo-dependent behavior in JS (see documentation)
Add a country-specific CSS class to the <body>-Tag (via AJAX).
This requires the JS Helper functions, either by ticking the option above, or by enqueuing it manually for the sites that need it.
Resolve shortcodes (via AJAX).
(JS Helper functions are added automatically for pages that contain ajax shortcodes.)
ALL OF THESE ARE ON, when I test using test lookup it shows my IP and all info. Can we get more assistance, please?
Thanks!
Are there JS execution errors (check in the development console)? – If yes, please copy them here. If no:
In the HTML, do you find the class “js-geoip-detect-show-if” ? – If no, the shortcodes are not evaluated server-side.
If yes, change the shortcode to :
[geoip_detect2_show_if country=”CA”] TEXT [else] ELSE [/geoip_detect2_show_if]
to check if the “else” condition is triggered.
There are no console errors, it simply says get_info.js:45 Geolocation IP Detection: Using cached response but this is not an error.
I do indeed see the class js-geoip-detect-show-if see below:
I replaced the shortcode with [geoip_detect2_show_if country=”CA”] TEXT [else] ELSE [/geoip_detect2_show_if] as instructed and all I see is the word ELSE nothing else appears…
<div class="itemBody kl-blog-page-body">
<!-- Blog Image -->
<!-- Blog Content -->
<span class="js-geoip-detect-show-if geoip-hidden" style="display: none;" data-options="{"skip_cache":false,"lang":["en","en"],"default":"","parsed":{"op":"and","not":0,"conditions":[{"p":"country","v":"\u201dca\u201d"}]}}"> TEXT </span><span class="js-geoip-detect-show-if geoip-shown" style="" data-options="{"skip_cache":false,"lang":["en","en"],"default":"","parsed":{"op":"and","not":1,"conditions":[{"p":"country","v":"\u201dca\u201d"}]}}"> ELSE </span>
Hopefully we can resolve this soon!
Ok then the shortcode works, but probably it does not detect “CA” correctly.
Can you add this please:
Detected country: [geoip_detect2 property=”country.isoCode”]
Hi there,
I added this shortcode alone
[geoip_detect2 property=”country.isoCode”]
and tried doing this [geoip_detect2_show_if country=”CA” property=”country.isoCode”] TEXT [/geoip_detect2_show_if] currently both are on the page….
This is what I get in the HTML…still does not show anything….
<div class="itemBody kl-blog-page-body">
<!-- Blog Image -->
<!-- Blog Content -->
<span class="js-geoip-detect-shortcode" data-options="{"skip_cache":false,"lang":["en","en"],"default":"","property":"country.isoCode"}"></span>
<span class="js-geoip-detect-show-if geoip-hidden" style="display: none;" data-options="{"skip_cache":false,"lang":["en","en"],"default":"","property":"country.isoCode","parsed":{"op":"and","not":0,"conditions":[{"p":"country","v":"\u201dca\u201d"}]}}"> TEXT </span><span class="js-geoip-detect-show-if geoip-shown" style="" data-options="{"skip_cache":false,"lang":["en","en"],"default":"","property":"country.isoCode","parsed":{"op":"and","not":1,"conditions":[{"p":"country","v":"\u201dca\u201d"}]}}"></span>
<p></p>
</div>
1. Try this shortcode: [geoip_detect2_user_info]
Is the IP correct?
2. Try calling the site in the private mode of the browser. (Because AJAX mode caches the looked up data for 1 week by default, private mode looks it up again.)
Hi there,
This is what I get in both incognito and regular chrome browser. The IP is fine.
IP of the user: 107.XXX.13.XXX
Data from: HostIP.info Web-API
What could the issue be?