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
πΊπΈ

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.
Contact WPLocation with your software versions and the result you expected. Keep keys and customer data private.
