Skip to main content

Custom Event and Location Fields

Events come with fields for dates, a location and tickets. Attributes let you add fields of your own: a dress code, a minimum age, the name of the teacher. You define each attribute once, it then appears as a field in the event editor, and you place it in your formats with a placeholder.

Locations have the same feature, for details such as parking or wheelchair access.

Attributes or WordPress custom fields​

There are two ways to add extra information. They store data in the same place, as post meta, so you can move between them.

AttributesCustom fields
Who decides which fields existYou, in the settings. Editors only see the fields you defined.Whoever edits the event. Any name and value can be added.
Fixed list of choicesYes, as a dropdown.No.
Each field once per eventYes.No, a name can be repeated.
On the front-end submission formYes.No, wp-admin only.
On by defaultYes.No.

Use attributes unless you have a reason not to. They keep the names and values consistent from one event to the next.

Define an event attribute​

  1. Go to Events then Settings then General then General Options and check that Enable event attributes? is set to Yes.

  2. In the Event Attributes box below it, add one line for each attribute, using the syntax in the table below.

    Two attributes: a free text field and a dropdown with three choices.

  3. Click Save Changes.

  4. Edit an event. The Attributes box (the Attributes tab in the block editor) now has a field for each line you added.

WriteYou get
#_ATT{Speaker}A text field labeled Speaker.
#_ATT{Speaker}{To be announced}A text field. Events where it is left empty show To be announced.
#_ATT{Dress Code}{Informal|Smart casual|Black tie}A dropdown with those choices, separated by the pipe character. The first choice is the default.

The text in the first pair of braces is the attribute's name. It is the label editors see, and it is how you refer to the attribute in a format, so type it the same way everywhere.

The same two attributes in the event editor.

Show an attribute on your site​

An attribute is not shown anywhere until you add it to a format. Put its placeholder where you want the value to appear, in any format in Events then Settings then Formatting:

{has_location}<p>Where: #_LOCATIONLINK</p>{/has_location}
<p>Speaker: #_ATT{Speaker}</p>
<p>Dress code: #_ATT{Dress Code}</p>

In a format you only need the name. The choices or the default value belong on the line in the Event Attributes box, and apply wherever that attribute is used.

Because attributes are stored as post meta under their name, a developer can also read them in a theme with get_post_meta().

Define and display in one step​

Events Manager also finds attributes written directly into your main event and location formats, such as the event list format and the single event page format. Adding #_ATT{Speaker} to one of those both creates the field and displays it. The Event Attributes box is the dependable place to define them, because not every format is scanned, and it keeps all your choices in one place.

Location attributes​

Location attributes work the same way, with these differences:

EventsLocations
SwitchEnable event attributes?Enable location attributes?
Where you define themEvent AttributesLocation Attributes
Placeholder#_ATT{Name}#_LATT{Name}
Where you fill them inThe Attributes box of an eventThe Attributes box of a location

The location settings are further down the same General Options box, under Location Settings and Physical Locations. A #_LATT placeholder can be used in location formats and in event formats, where it shows the value from the event's location.

Change an attribute later​

  • Add a choice to a dropdown. Edit the attribute's line in the Event Attributes box. The new choice is offered in every event.
  • Turn a text attribute into a dropdown. Add the choices to its line. Events keep the value they have. When you next save an event whose value is not one of the choices, the first choice is stored in its place.
  • Rename an attribute. A renamed attribute is a new field. Values saved under the old name stay with their events but are no longer shown, so rename before you start filling attributes in.
  • Remove an attribute. Delete its line and remove the placeholder from your formats. The saved values stay in the database.

Custom fields​

To use WordPress custom fields on events, set Enable event custom fields? to Yes in Events then Settings then General then General Options. For locations the setting is Enable location custom fields?. Both are off by default.

A Custom Fields box then appears in the classic editor, where you add name and value pairs as you would on a post. In the block editor, WordPress keeps this panel hidden until you switch it on in the editor's preferences.

Custom fields are only available in wp-admin, and are not offered on the front-end submission forms. To display one in a format, use #_ATT{name} with the custom field's name.

Limits​

  • Text attributes accept HTML only from users who are allowed to post unfiltered HTML, such as administrators. For everyone else, including guests on the submission form, disallowed HTML is stripped when the event is saved.
  • A dropdown needs at least two choices. One value in the second pair of braces is treated as a default for a text field.

Troubleshooting​

The Attributes box says attributes must be defined first

No attribute has been defined yet. Add at least one line to Event Attributes in the settings.

There is no Attributes box at all

Enable event attributes? is set to No.

The placeholder shows nothing

The event has no value for that attribute and the attribute has no default. Check that the name in the placeholder matches the name in the Event Attributes box exactly, including capital letters and spaces.