WP Manifestindependent plugin directory
manifest / builders / location-conditional-content

Location Conditional Content

A lightweight WordPress plugin that lets you show or hide content and Elementor elements based on the visitor's country

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/rizwanali490/location-conditional-content/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

A lightweight WordPress plugin that lets you show or hide content and Elementor elements based on the visitor's country — similar to the geolocation feature in If-So Dynamic Content.

Perfect for geo-targeted offers, region-specific messaging, country-based promotions, or compliance requirements.

Features

  • Shortcode support
    [location_conditional country="AF,US" not="no"]Your content[/location_conditional]

  • Elementor integration
    New "Location Visibility" section in the Advanced tab of every widget, section, and container
    → Enable/disable per element
    → Show or hide based on selected countries
    → Multi-select country dropdown (full ISO 3166-1 list)

  • Accurate country detection
    Uses ipapi.co (free tier: 30,000 requests/month)
    Cached for 24 hours per IP to minimize API calls

  • No global performance hit
    Only conditional elements are affected
    Compatible with Elementor caching when you set Cache Setting → Inactive on conditional elements

Installation

  1. Download and unzip the plugin
  2. Upload the location-conditional-content folder to /wp-content/plugins/
  3. Activate the plugin through Plugins → Installed Plugins in WordPress
  4. (Optional) Use the shortcode or edit Elementor elements

No settings page — controls live inside Elementor or via shortcode.

Usage Examples

1. Shortcode (anywhere in content)

[location_conditional country="AF"]
    <div class="alert alert-success">Special offer for visitors in Afghanistan!</div>
[/location_conditional]

[location_conditional country="US,CA" not="yes"]
    <p>This message is hidden in the United States and Canada.</p>
[/location_conditional]

2. Elementor (recommended for visual builder)

  1. Edit page with Elementor

  2. Select any widget, section, or container

  3. Go to Advanced tab → Location Visibility

  4. Enable the condition

  5. Choose Show or Hide mode

  6. Select one or more countries

  7. (Important) In the same Advanced tab → set Cache Setting to Inactive→ This prevents Elementor from caching the element and showing stale geo-content

How Country Detection Works

  • Visitor IP → https://ipapi.co/{ip}/country/ (returns ISO 3166-1 alpha-2 code, e.g. "AF")

  • Result cached 24 hours using WordPress transients

  • Handles proxies / Cloudflare via standard forwarded headers

  • Fallback: hide content if lookup fails

Requirements

  • WordPress 6.0+

  • PHP 7.4+

  • Elementor (free version is enough)

Notes & Limitations

  • Elementor Caching: Must manually set Cache Setting → Inactive on each conditional element (or disable Element Caching globally) — otherwise cached output may be shown to wrong visitors.

  • Country-level only (no cities/regions in this version)

  • Relies on third-party free API (ipapi.co) — rate limits apply on very high traffic

  • Accuracy ~95–98% for country detection (typical for IP geolocation)