Location-based WordPress Menus – 5 min setup

Set up dynamic menus based on the user's location: continent, country, state, city, or timezone.
wordpress conditional menu 1

Use cases

  • Include a dynamic menu item that points to the visitor’s nearest branch.
  • Direct users to country-specific help centers or language-specific support articles.
  • Country-specific pricing or shop – show menu items that link to the appropriate shop domain.

Step-by-step: How to set up location-based menu item

The setup involves two main steps: (1) creating a trigger that defines the locations and their corresponding menu items, and (2) adding that trigger to your WordPress menu.

  1. Download and activate the If-So Dynamic Content plugin.
  2. On your WordPress dashboard, go to If-SoAdd New Trigger. Screenshot
  3. In version A, select the geolocation condition and choose the location(s) where the dynamic menu item will appear. Screenshot
  4. In the version A content field, switch the WYSIWYG editor to Code mode and paste the HTML line below, while replacing https://example.com with the page URL you want the menu item to lead to and Item Name with your desired label. Screenshot
<a href="https://example.com">Item Name</a>
  1. On your WordPress dashboard, go to AppearanceMenus.
  2. Click Custom Links to add a new custom menu item, paste the trigger’s shortcode in the Link Text field, and enter # in the URL field.
  3. In the Link Text field, paste the trigger’s shortcode. Screenshot

Screenshots

add a new trigger 1
Create a trigger
Select location(s)
HTML code
Add the HTML code for the menu item
Custom link
Add a custom link to your menu

FAQ

How accurate is If-So’s geolocation detection?

If-So’s geolocation detection is highly accurate, using both IP-based databases and the HTML5 Geolocation API. Accuracy depends on the method and user consent. HTML5 detection can pinpoint city-level precision, while IP-based data may vary slightly based on the user’s ISP.

Can users manually select their location if the automatic detection is wrong?

Yes. You can enable the manual user location feature, allowing visitors to override their detected location by selecting a continent, country, state, or city from a dropdown list.

Can I combine multiple geolocation conditions in one trigger?

Yes. You can create multiple versions within the same trigger, each with a different geolocation condition, to target various locations.

Does geolocation detection work with page caching?

Yes. If-So’s geolocation detection works seamlessly with all caching systems by using AJAX loading. Dynamic content is loaded after the cached page is served, ensuring that each visitor sees the correct version based on their location without affecting performance.

Didn’t find what you need?

Christmas Sale!
Up to 40% Off