Skip to main content

Search Form Parameters

The search form is set up once, in Events then Settings then Formatting then Search Form, and those settings apply wherever the form appears. The parameters on this page override a setting for one form at a time, in a shortcode attribute or in PHP.

[event_search_form search_geo="0" search_categories="1" views="list,map"]

They are accepted wherever a search form can be shown:

A few rules apply to every table below:

  • bool values are 1 or 0 in a shortcode. PHP also accepts true and false.
  • string[], int[] and mixed[] values are comma-separated in a shortcode, such as views="map,calendar". PHP also accepts an array.
  • A default of settings means the value comes from the matching option in Events then Settings then Formatting then Search Form.
  • On a locations search form, the dates, categories, tags and virtual events fields are always off.

General options​

AttributeTypeDefaultDescription
ajaxbool1Whether results load without a page reload. The default is the EM_AJAX_SEARCH constant.
idstringrandom numberIdentifies this form. It is added to the IDs of the form's HTML elements, so set your own value, such as id="main", when your CSS or JavaScript needs stable IDs.
css_classesstring[]Extra CSS classes for the form's wrapping element.
search_urlstringevents or locations pageThe page the form submits to when AJAX is off.
search_actionstringsearch_eventsThe action name sent with a search. For custom development only.

Main search form​

The main search form is the bar shown above a list or calendar, or on its own. It can hold a text field, a location field and a date picker, plus buttons for views, sorting and the advanced options.

The main search bar on the Maple Bay Events page.

AttributeTypeDefaultDescription
show_mainboolsettingsShows the main search bar. It is hidden automatically when none of its three fields (text, location, dates) is enabled. With 0, only the advanced options are shown.
search_buttonstringsettingsThe text on the search button.
sortingboolsettingsShows the button for changing the order of the results.
views string[]settingsThe views a visitor can switch between: list, list-grouped, grid, map, calendar for events, and list, grid, map for locations. With one view or none, the view switcher is hidden.
viewstringsettingsThe view shown first. Falls back to list if the value isn't a known view.

Search term​

A text field that searches event names and descriptions, and the names and addresses of their locations.

AttributeTypeDefaultDescription
search_termboolsettingsShows the text field in the main bar.
search_term_labelstringsettingsThe placeholder text inside the field.
searchstringText to fill the field with at the start.

Dates (scope)​

A date picker for a single date or a range. Events forms only.

AttributeTypeDefaultDescription
search_scopeboolsettingsShows the date picker in the main bar.
scope_labelstringsettingsThe placeholder text inside the date field.
scope_seperatorstringsettingsThe text between the two dates of a range, such as to. The attribute name is spelled this way.
scope_formatstringsettingsHow chosen dates are displayed, in flatpickr date tokens: d/m/Y shows 31/12/2027.
scopestringsettingsThe dates the list starts with, as any scope value. Preset names such as future choose the results without filling in the date picker.

Location (geolocation)​

A field where the visitor types a place name, picks a suggestion, and gets the events near it.

Before you start

This field uses Google's place suggestions, so it needs a Google Maps API key.

AttributeTypeDefaultDescription
search_geoboolsettingsShows the location field in the main bar.
geo_labelstringsettingsThe placeholder text inside the field.
geostringText to fill the field with at the start. It only becomes a search once the visitor clicks the field and picks a suggestion.
nearstringCoordinates to search around at the start, as latitude,longitude.
near_distanceintsettingsThe starting search radius.
near_unitstringsettingsThe unit of the radius, mi or km.

The advanced search holds the remaining filters: categories, tags, country, region, state and town, and copies of the main bar's fields if you want them. It opens in a popup from a button in the main bar, or sits inline under the bar.

The advanced search popup.

Fields that appear in both places stay in step: a date picked in the popup also shows in the main bar.

AttributeTypeDefaultDescription
show_advancedboolsettingsShows the advanced search. By default it is on only when the setting is on and at least one advanced field is enabled.
advanced_modestringsettingsmodal for a popup or inline for a section under the main bar. Forced to inline when the main bar is hidden, since nothing could open a popup.
advanced_hiddenboolsettingsFor inline mode, whether the section starts collapsed. A popup always starts closed.
advanced_triggerboolsettingsShows the button in the main bar that opens the advanced search.
search_advanced_textstringsettingsThe label of that button, shown as its tooltip.
search_advanced_stylestringsettingsaccordion puts each filter in an expandable section with its options listed. headings shows a plain heading above each filter, with categories and tags as drop-downs.

Search term​

AttributeTypeDefaultDescription
search_term_advancedboolsettingsShows the text field in the advanced search.
search_term_label_advancedstringsettingsIts label.

Dates (scope)​

AttributeTypeDefaultDescription
search_scope_advancedboolsettingsShows the date picker in the advanced search.
scope_label_advancedstringsettingsIts label.
scope_seperator_advancedstringsettingsThe text between the two dates of a range.
scope_format_advancedstringsettingsHow chosen dates are displayed, in flatpickr date tokens.

Categories​

Events forms only.

AttributeTypeDefaultDescription
search_categoriesboolsettingsShows the category filter.
category_labelstringsettingsThe heading of the filter.
categories_labelstringsettingsThe text for "no category chosen", such as "All Categories".
categories_placeholderstringsettingsThe placeholder in the box for finding a category by typing.
categories_clear_textstringClear SelectedThe text of the link that clears the chosen categories.
categories_count_textstring%d SelectedThe text that counts the chosen categories. %d is the number.
categories_includemixed[]settingsOffer only these categories, by ID or slug: jazz,123,rock.
categories_excludemixed[]settingsLeave these categories out of the filter.
categorymixed[]0Categories chosen at the start, by ID or slug.

Tags​

Events forms only.

AttributeTypeDefaultDescription
search_tagsboolsettingsShows the tag filter.
tag_labelstringsettingsThe heading of the filter.
tags_labelstringsettingsThe text for "no tag chosen", such as "All Tags".
tags_placeholderstringsettingsThe placeholder in the box for finding a tag by typing.
tags_clear_textstringClear SelectedThe text of the link that clears the chosen tags.
tags_count_textstring%d SelectedThe text that counts the chosen tags.
tags_includemixed[]settingsOffer only these tags, by ID or slug.
tags_excludemixed[]settingsLeave these tags out of the filter.
tagmixed[]0Tags chosen at the start, by ID or slug.

Location​

AttributeTypeDefaultDescription
search_geo_advancedboolsettingsShows the location (geolocation) field in the advanced search.
geo_label_advancedstringsettingsIts label.

Geolocation options​

Once the visitor has picked a place in the location field, the advanced search shows distance options in place of the country, region, state and town drop-downs.

AttributeTypeDefaultDescription
search_geo_unitsboolsettingsShows the distance options.
geo_units_labelstringsettingsTheir label.
geo_distance_valuesint[]settingsThe distances offered, such as 5,10,25,50,100.
near_distanceintsettingsThe distance chosen at the start.
near_unitstringsettingsThe unit chosen at the start, mi or km.

Geographic search options​

Drop-downs for country, region, state and town. Choosing a value in one narrows the choices in the others to places that exist within it.

AttributeTypeDefaultDescription
search_countriesboolsettingsShows the country drop-down.
country_labelstringsettingsIts label.
countries_labelstringsettingsThe text for "no country chosen", such as "All Countries".
countrystringsettingsThe country chosen at the start, as a two-letter code. Applies only while the country drop-down is shown.
search_regionsboolsettingsShows the region drop-down.
region_labelstringsettingsIts label.
regionstringThe region chosen at the start.
search_statesboolsettingsShows the state drop-down.
state_labelstringsettingsIts label.
statestringThe state chosen at the start.
search_townsboolsettingsShows the town drop-down.
town_labelstringsettingsIts label.
townstringThe town chosen at the start.

Virtual events​

Since 7.5 A checkbox that limits results to events that can be attended online. Hybrid events are included. Events forms only, and only while online locations are enabled. See Hybrid and Virtual Events.

AttributeTypeDefaultDescription
search_onlineboolsettingsShows the checkbox. The setting is Show virtual events filter?.
online_labelstringsettingsIts label. The default is "Virtual events only".
accessstringSet to online to have the checkbox ticked at the start.

Eventful locations​

On a locations search form, a checkbox labeled Eventful Locations? limits results to locations with upcoming events.

AttributeTypeDefaultDescription
search_eventfulbool1Shows the checkbox. Locations forms only.

Examples​

A search bar with only a text field and a date picker, no advanced options:

[event_search_form search_geo="0" show_advanced="0"]

An events list with a search form whose category filter offers three categories:

[events_list has_search="1" search_categories="1" categories_include="music,theater,family"]

The same in PHP, with stable IDs for styling:

echo EM_Events::output( array(
'has_search' => 1,
'id' => 'main',
'search_categories' => 1,
'categories_include' => array( 'music', 'theater', 'family' ),
) );