Now available

WPLocation Free is on WordPress.org

View the plugin β†—

WPLocation

Country-aware content for WordPress

  • Features
  • Demo
  • Add-ons
  • Pricing
  • Blog
  • Account
  • Get Pro
← All documentation/WPLocation shortcodes
Free

WPLocation shortcodes

For the current releases: Free 1.1.14 (WordPress.org) and Pro 1.4.5.

On this page
  1. Show content to selected countries
  2. Hide content from selected countries
  3. Display the detected country
  4. Test the rendered page
  5. Attribute reference
  6. Combining include and exclude
  7. Choose the right editor tool
Free setupPro & licensingMy account & downloadsFree on WordPress.org β†—

This guide applies to Free 1.1.0. See the Free installation guide.

Older standalone content may contain the legacy locationtarget tag. The WordPress.org plugin does not register that tag; migrate it before replacing an old build. Use wplocation_target in new content; the WordPress.org directory edition uses only the prefixed tag.

Shortcodes are useful when part of a page or post should vary by country. Use a page or post rule when the entire URL should be hidden or shown.

Show content to selected countries

Add a Shortcode block in the WordPress editor and use the wplocation_target shortcode. The country attribute accepts names or two-letter codes separated by commas:

Content for visitors in the US or Pakistan

Only visitors in the selected known countries see the enclosed content.

Hide content from selected countries

Use exclude_country when most known countries should see the section except the ones listed:

If a visitor’s country is unknown, the enclosed content is hidden for either type of rule.

Display the detected country

The wplocation_country shortcode can show the country name, code, or flag emoji. Supply a fallback for visitors whose country cannot be detected:

United States
US
πŸ‡ΊπŸ‡Έ
Shortcode examples on the current WPLocation Shortcodes screen
Shortcode examples on the current WPLocation Shortcodes screen (local WordPress test site)View full-size screenshot

Test the rendered page

Save the content, then check the rendered page and your site cache. A shared cached HTML page can expose the wrong location-specific section. Do not use a shortcode to protect confidential material. If no country is detected, check WPLocation β†’ Diagnostics.

Attribute reference

Shortcode Attribute What it does
wplocation_target country Shows the enclosed section only for matching countries.
wplocation_target exclude_country Hides the section for matching countries.
wplocation_country format Use name (default), code, or flag.
wplocation_country fallback Text shown when no country is detected.

Use two-letter country codes when possible; they are easier to review than free-form names. Separate multiple values with commas. The shortcode compares codes and supported country names without case sensitivity. For example, country="US,PK" matches either country.

Combining include and exclude

If both attributes are present, a visitor must match country and must not match exclude_country. An exclusion wins over an inclusion. A wplocation_target shortcode with neither attribute shows nothing, and an unknown country never reveals its enclosed content.

Shown to detected US visitors only

Choose the right editor tool

In the block editor, the Country visibility block can wrap other blocks without typing shortcode syntax. Use a page rule or post rule for a whole URL. All of these are server-rendered decisions, so follow the cache and CDN checklist before publishing.

Where to next?

Choose the right country rule β†’Check your cache and CDN β†’Browse all guides β†’
Need help with this guide?

Contact WPLocation with your software versions and the result you expected. Keep keys and customer data private.

Free on WordPress.org β†—Release notesFree support forumPro support & report an issue

Company

  • About us
  • Contact
  • Terms & Conditions
  • Privacy Policy

Product

  • Features
  • WPLocation Pro
  • Pricing
  • Add-ons roadmap
  • Get WPLocation

Resources

  • Blog
  • Documentation
  • Installation
  • Shortcodes
  • Changelog

Account & Support

  • My Account & Licenses
  • Contact Support
  • Blocked-content behavior

Copyright © 2026. WPLocation is a project of TechAbout LLC.
Questions? [email protected]