AJAX mode

You are here:

Ajax mode was conceived in order to make the Geotargeting plugin compatible with all cache plugins around. Once enabled, the shortcodes, geotargeted posts or products, redirects,etc will be updated after the page it's loaded by doing an AJAX request with Javascript. Thanks to this we are able to bypass the page cache generated by plugins.

Also AJAX mode it's needed when you use GPS Geolocation because the browser use javascript to get user's location.

Important:

  • Geotargeted categories are not supported by ajax.
  • Posts / products needs to be compliant with WordPress coding standards. This mean that each posts needs to have an ID attribute such as post-12 (where 12 is post ID ) or class attribute with same value. Also when content is replaced with a message the posts needs to have class attribute of “entry-content” in order to know where to place the message.
  • When you have geotarget posts, every page will consume a request*

Geo Redirects

The difference between this mode and regular mode is that the user sees the page for a second or less. Then, a full screen overlay it's presented to inform that he is being redirected to the right page.

Geo Blocker

The difference between this mode and regular mode is that the user sees the page for a second or less.Then, a full screen overlay it's presented to inform that the page it's not available to the user.

* About the extra requests

When ajax mode it's enabled the plugin will get a list of all posts of the site where you added geolocation even if not the queried page. This happens so those pages can be removed from widgets or similar elements. If you want to save requests because you know this functionality it's not needed you could add the following filter:


add_filter( 'geot/get_geotargeted_posts_pass_id', function( $pid, $ajax_data ) {
        // will save requests in all single pages and posts that are not geotargeted
        if( $ajax_data['is_singular'] ) {
           return $ajax_data['pid'];
        }
});