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

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

How does the show/hide posts by geolocation work?

Assign a category to your posts. If-So lets you decide which post categories are shown or hidden for visitors from specific countries. The same method can also be applied with other If-So conditions.

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, testimonials, or news by country, state, or city.

Step-by-step: How to show or hide posts based on the user’s location

  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.

FAQ

How accurate is IP-to-location?

IP-to-location is typically accurate at the country level and often at the region or city level. Accuracy varies by ISP and user setup. For precise results, use the HTML5 Geolocation API (requires consent) or allow manual location selection.

How does If-So detect user location?

If-So can use an IP-to-location database, the HTML5 Geolocation API (after consent), or a manual self-location selection form that overrides detection.

Can I redirect users who open a hidden post via a direct link?

Yes. Set a Redirect URL in the rule. If a visitor from a restricted country lands on a hidden post directly, they’ll be redirected to the page you choose.

Does this work with caching?

Yes. If-So works with all caching systems.

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