One of the newest tools in our plugin repertoire is Simple Locator by developer Kyle Phillips.
It allows you to add location data — longitude, latitude, address, and more — to any WordPress post or custom post type, and both display it and search by it. It’s one of those plugins that makes WordPress that much more usable.
Simple Locator comes with a built in “Locations” post type that allows you to create individual “locations” posts, but if you’re using your own custom post type, you can use that instead.
For example, if you’re a business with multiple stores, you can create an entry for each store and choose the address to go along with it. Or, if you’re an association, you can add a location to your members’ listings.
With a location attached to the entry, you can display a Google Map alongside that post’s content. Additionally, any entry that has location data can be included in Simple Locator’s built-in location search.
The search function has a ton of controls, so you don’t need to build a complex WordPress search engine to find entries with location data.
The location search form isn’t that complicated to build. Simple Locator comes with a built-in shortcode —
[wp_simple_locator] — to generate the form, or you can use an included widget.
There are a number of options you can set with the shortcode (click here to see them), but here’s an example of how the shortcode may look:
[wp_simple_locator distances="5,10,20,50,100" mapcontainer="#fullpage-map" buttontext="icon-search" addresslabel="U.S. Zip Code or City" mapcontrols="show" resultscontainer="#mapresults" mapcontrolsposition="RIGHT_BOTTOM" placeholder="Enter U.S. Location"]
One of the great features of the search form is the ability to search by distance; i.e., find a location within a set number of miles of your location. It makes it incredibly simple to discover only places around you, which is often the goal of a location search.
You can also enable (or disable) Google Autocomplete, so it’s easier for the user to search and so there is consistent search data being used.
We had the honor to work on the website for the National Gaucher Foundation, an organization that serves U.S. patients with Gaucher disease and their families.
As part of their website, they provide a “Treatment Finder” so that users can find hospitals and locations across the country that treat Gaucher’s disease. Because we needed to include a fair amount of custom data with each treatment location, we used our own custom post type with fields created using Advanced Custom Fields (ACF).
The integration between Simple Locator and ACF is great, as Simple Locator can look into a custom field created by ACF to pull location data. We created a Google Map field for the custom post type, and after the user selects the location using the ACF field, it auto-populates two additional fields we created – latitude and longitude. It’s from these fields that Simple Locator gets what it needs.
If your website requires showing users where your locations or memberships are, Simple Locator is a great way to integrate location data and build an easy-to-use location search.