Show/Hide posts by geolocation (or any other condition)
Show/Hide posts by geolocation (or any other condition)
Control post visibility by location (continent, country, state, or city) and other dynamic rules.
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
Assign a unique category to the posts you want to show or hide. Screenshot
On your WordPress dashboard, go to If-So → Settings → Geolocation tab. Screenshot
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
Click Save settings.
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.