GeoTargeting Lite – WordPress Geolocation Shortcodes

Below, you’ll find a detailed guide on how to add the GeoTargeting Lite – WordPress Geolocation Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the GeoTargeting Lite – WordPress Geolocation Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the GeoTargeting Lite – WordPress Geolocation Plugin and the shortcodes it provides:

Plugin Icon
GeoTargeting Lite – WordPress Geolocation

"GeoTargeting Lite – WordPress Geolocation is a powerful plugin that enables the customization of website content based on the geographical location of your visitors. Enhance your user experience with GeoTargeting."

★★★☆✩ (32) Active Installs: 2000+ Tested with: 6.1.4 PHP Version: false
Included Shortcodes:
  • [geot]
  • [geot_country_name]
  • [geot_country_code]

GeoTargeting Lite – WordPress Geolocation [geot] Shortcode

The Geotargeting shortcode is a powerful tool that filters content based on the user’s location. It uses IP, country, and region parameters to customize what users see. The ‘geot_filter’ function extracts user details like IP, country, and region. If a user’s location matches the targeted or excluded areas, it displays the content.

Shortcode: [geot]

Parameters

Here is a list of all possible geot shortcode parameters and attributes:

  • ip – Identifies visitor’s IP address automatically.
  • country – Targets content to specific country.
  • region – Targets content to specific region.
  • exclude_country – Excludes content from specific country.
  • exclude_region – Excludes content from specific region.

Examples and Usage

Basic example – A simple usage of the geotargeting shortcode to filter content based on a user’s country.

[geot country="US"]This content is only visible to users from the United States.[/geot]

Advanced examples

Using the shortcode to filter content based on both the user’s country and region. This content will only be visible to users from California, United States.

[geot country="US" region="California"]This content is only visible to users from California, United States.[/geot]

Using the shortcode to exclude certain regions from seeing the content. In this example, the content will be visible to all users from the United States, except those from California.

[geot country="US" exclude_region="California"]This content is not visible to users from California, United States.[/geot]

Using the shortcode to exclude certain countries from seeing the content. In this example, the content will be visible to all users except those from the United States.

[geot exclude_country="US"]This content is not visible to users from the United States.[/geot]

PHP Function Code

In case you have difficulties debugging what causing issues with [geot] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('geot', array( $shortcodes, 'geot_filter') );

Shortcode PHP function:

function geot_filter($atts, $content)
	{
		extract( shortcode_atts( array(
			'ip' 				=>$this->functions->getUserIP(),
			'country'			=>'',
			'region'			=>'',
			'exclude_country'	=>'',
			'exclude_region'	=>''
		), $atts ) );
		
				
		if ( $this->functions->target( $country, $region, $exclude_country, $exclude_region ) )
			return do_shortcode( $content );
			
		return '';
	}

Code file location:

geotargeting/geotargeting/includes/class-geotarget.php

GeoTargeting Lite – WordPress Geolocation [geot_country_name] Shortcode

The GeotargetingWP shortcode is a function that returns the name of the visitor’s country. It uses the shortcode ‘geot_country_name’ to display this information. This shortcode is part of the GeotargetingWP plugin and is used to enhance user experience by personalizing content.

Shortcode: [geot_country_name]

Examples and Usage

Basic example – The geotargeting plugin shortcode is used to display the name of the country of the visitor’s IP address.

[geot_country_name /]

Under the title ‘Advanced examples’:

Utilizing the shortcode to customize the display of the country name based on specific attributes. The shortcode will first try to display the country name based on the IP address, but if not found, it will display a default value.

[geot_country_name default="Not found" /]

Another advanced example is to use the shortcode within a text to dynamically display the country name. The country name will be inserted into the text at the location of the shortcode.

Welcome to our website, [geot_country_name /] visitor!

PHP Function Code

In case you have difficulties debugging what causing issues with [geot_country_name] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('geot_country_name', array( $shortcodes, 'geot_name') );

Shortcode PHP function:

function geot_name($atts, $content)
	{
		return geot_country_name();
	}

Code file location:

geotargeting/geotargeting/includes/class-geotarget.php

GeoTargeting Lite – WordPress Geolocation [geot_country_code] Shortcode

The GeotargetingWP shortcode allows for dynamic content display based on a user’s location. Shortcode Name: GeotargetingWP shortcode is designed to return the country code of the user’s location. This helps in customizing content to match the user’s geographical area.

Shortcode: [geot_country_code]

Examples and Usage

Basic example – In this example, the geotargeting plugin shortcode is used without any parameters or attributes. It will simply return the country code of the visitor’s location.

[geot_country_code /]

Advanced examples

Example 1 – Using the shortcode to display different content based on the visitor’s country code. In this case, the content will only be displayed if the visitor’s country code matches the one specified in the ‘if’ attribute.

[geot_country_code if="US"]This content is only for visitors from the United States.[/geot_country_code]

Example 2 – The shortcode can also be used in combination with other shortcodes. Here, the ‘geot_country_code’ shortcode is used within the ‘contact_form’ shortcode to display a different contact form based on the visitor’s country code.

[contact_form id="[geot_country_code /]"]

PHP Function Code

In case you have difficulties debugging what causing issues with [geot_country_code] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('geot_country_code', array( $shortcodes, 'geot_code') );

Shortcode PHP function:

function geot_code($atts, $content)
	{
		return geot_country_code();
	}

Code file location:

geotargeting/geotargeting/includes/class-geotarget.php

Conclusion

Now that you’ve learned how to embed the GeoTargeting Lite – WordPress Geolocation Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *