Show/Hide posts by geolocation (or any other condition)

Control post visibility by location (continent, country, state, or city) and other dynamic rules.
posts by geolocation

How does the show/hide posts by geolocation work?

posts by geolocation UI

If-So allows you to show or hide pages and posts by geolocation (and other If-So conditions) – no coding required.

The show/hide posts by geolocation feature works by assigning a category to the relevant page or post, and then using If-So to define whether posts in that category should be hidden or shown only in specific locations.

How hidden posts are handled

  • Excluded from post listing pages (for example, the main blog page).
  • Excluded from post listings created with page builder blocks or elements
  • Excluded from the site’s internal search (when enabled and configured according to WordPress guidelines)
  • Still accessible via direct links, with an option to redirect visitors to a different page

How does If-So detectes the user’s location?

The user’s location can be detected automatically using an IP-to-location database or more precisely through the HTML5 Geolocation API, which requires the visitor’s consent. Additionally, a manual self-location selection option is available, allowing users to override the detected location if needed.

Use cases

  • Display country-specific prices or promotions.
  • Offer localized discounts or deals by country.
  • Hide posts for countries where the content is not relevant or available, including site search results.
  • Show unique products or posts to previous purchasers, new customers, or returning customers (using other If-So conditions).
  • Localize case studies, or news by country, state, or city.

Step-by-step: How to show or hide posts by geolocation

  1. Download and activate the If-So Dynamic Content plugin and the If-So Geolocation Extension.
  2. Assign a unique category to the posts you want to show or hide. Screenshot
  3. On your WordPress dashboard, go to If-SoSettingsGeolocation tab. Screenshot
  4. Under Post visibility by location, click Add rule, then set the category, the location, and a Redirect URL (optional, for users who reach a hidden post via a direct link). Screenshot
  5. Click Save settings.
  6. Visit a VPN or testing tool to simulate locations and verify that categories are shown/hidden as expected.

Screenshots

Assign a category
Assign a category to your posts
If So Geolocation
If-So → Settings → Geolocation
category post
Set up the category show/hide rules

Didn’t find what you need?

Christmas Sale!
Up to 40% Off