Before you begin, please review this article about setting up your Google Maps API Key. If you do not run through those steps, you may not be able to take advantage of the functionality described here.
One of the many great features exclusive to Events Calendar Pro is the ability to perform smart location-based searches when filtering calendar events. When viewing the main calendar page of a site that’s running Events Calendar Pro, you’ll see an additional option located next to the fields for month- and keyword-based searches.
Expanding on the basic venue options that are provided for calendar events in The Events Calendar, Events Calendar Pro includes support for saved venues and geolocation data. This geolocation data is precisely what enables the powerful location search capabilities of Pro, making it easier than ever for your users to find local events that match their interests.
For demonstration purposes, let’s try a basic search on our Demo Site using the Map View. When accessing your main calendar page in Map View, you’ll see all of your events plotted on a large map based on their venue location.
Simply enter an address, city, or other mappable location into the In a location field, then click the Find Events button to process your search. After a few moments, your map and the event listings below will refresh, and you’ll be presented with a smaller selection of nearby events (if any events are found within the specified radius).
This feature can be used for filtering events on any calendar view and works great with our Filter Bar add-on for even more precise filtering capabilities. When Filter Bar is used in tandem with Events Calendar Pro, you can adjust the radius for your location-based searches by using the Distance filter. This can be helpful if, for example, you’d like to search for events across multiple nearby metro areas, or if you’re looking to filter a calendar with a large number of events to display only those closest to your location.
Taking it Further
Hiding the Location Search Field
By default, the location search field is displayed in the Event Search Bar for all calendar views, including List, Month, Day, Week, Map, and Photo. If you’d prefer to limit location-based searches to map-based views only, you can achieve this with a simple settings toggle.
After logging in to your WordPress site’s admin, navigate to Events > Settings from the WordPress sidebar and click the Display tab. You’ll find the checkbox for Hide location search under the Basic Template Settings heading.
Select this box and click the Save Changes button at the bottom of the settings pane once you’re finished. Your changes will be applied immediately to your calendar views, and you’ll no longer see the location search option on non-map-based views.
Filtering Events by Location with WP_Query
If you’ve ever used WP_Query or our own tribe_get_events() function to create a customized display of event data, you’ll be pleased to know that we’ve recently added support for location-based filters in these queries! Beginning with Events Calendar Pro version 4.4.16, the arguments tribe_geoloc, tribe_geoloc_lat, and tribe_geoloc_lng are available for writing into your custom queries. For more information on location-specific and other changes added in this release, check out our complete release notes here.
We hope that this post helps to give you a solid understanding of how our location searches work and how your users can leverage this feature to make better use of your calendars! As always, if you should have any questions, we’re just a click away over at our help desk–please don’t hesitate to pay us a visit!