Skip to main content

Template Tags

Template tags are PHP functions you call from your theme's template files to print something from Events Manager, in the same way as WordPress's own template tags. They are for theme developers. If you are not editing PHP, the shortcodes and blocks do the same jobs.

A theme template, such as sidebar.php
<?php
if ( function_exists( 'em_events' ) ) {
em_events( array( 'scope' => 'future', 'limit' => 5 ) );
}

Wrapping calls in function_exists() keeps your theme working if Events Manager is deactivated.

How the functions work​

  • Print or return. Each function that prints has a twin that returns the HTML as a string. Swap em_ for em_get_: em_events() prints, em_get_events() returns.
  • Arguments. $args is an array of search parameters. The list and calendar functions also accept a query string, such as 'scope=future&limit=5'.
  • Formats. Lists use the formats from Events then Settings then Formatting unless you pass format, format_header or format_footer. See format parameters.
  • Underlying classes. The tags are thin wrappers. em_get_calendar() returns EM_Calendar::output(), and the list functions end up in EM_Events::output() and EM_Locations::output(). All are defined in em-template-tags.php in the plugin folder.

Lists and calendars​

em_events()​

em_events( $args = array() )

Prints a list of events.

ParameterTypeDefaultDescription
$argsarray or stringarray()General, event and location search parameters. Without a limit, the number of events comes from the settings.
em_events( array( 'category' => 'music', 'scope' => 'month', 'limit' => 10, 'pagination' => 1 ) );

em_locations()​

em_locations( $args = array() )

Prints a list of locations.

ParameterTypeDefaultDescription
$argsarray or stringarray()General and location search parameters.
em_locations( array( 'country' => 'US', 'eventful' => 1 ) );

em_calendar()​

em_calendar( $args = array() )

Prints a calendar of events.

ParameterTypeDefaultDescription
$argsarray or stringarray()Calendar, general, event and location search parameters.
em_calendar( array( 'calendar_size' => 'small', 'category' => 'music' ) );

em_events_list_grouped()​

em_events_list_grouped( $args = array() )

Prints a list of events split under date headings, by day, week, month or year.

ParameterTypeDefaultDescription
$argsarray or stringarray()The same parameters as em_events(), plus mode, date_format and header_format for the grouping.
em_events_list_grouped( array( 'mode' => 'monthly', 'scope' => '6-months' ) );
em_link( $text = '' )

Prints a link to the events page.

ParameterTypeDefaultDescription
$textstring''The link text. When empty, the title of the events page is used.
em_rss_link( $text = 'RSS' )

Prints a link to the RSS feed of events.

ParameterTypeDefaultDescription
$textstring'RSS'The link text.

Search forms​

em_event_search_form()​

em_event_search_form( $args = array() )

Prints the events search form.

ParameterTypeDefaultDescription
$argsarrayarray()Search form parameters.

em_location_search_form()​

em_location_search_form( $args = array() )

Prints the locations search form.

ParameterTypeDefaultDescription
$argsarrayarray()Search form parameters.

Front-end management​

These print the screens that let people submit and manage events, locations and bookings without going into the WordPress admin area. See Accepting User-Submitted Events.

em_event_form()​

em_event_form( $args = array() )

Prints the event submission form. Logged-out visitors get the guest version of the form when guest submissions are allowed in the settings.

ParameterTypeDefaultDescription
$argsarrayarray()Optional. event_archetype takes the post type of an archetype, to use that archetype's settings.

em_events_admin()​

em_events_admin( $args = array() )

Prints a table of the logged-in user's events, with links to add and edit them. The user needs the edit_events capability. A logged-out visitor sees the event submission form if guest submissions are allowed, and otherwise the message "You must log in to view and manage your events."

ParameterTypeDefaultDescription
$argsarrayarray()Optional. event_archetype, as above.

em_location_form()​

em_location_form( $args = array() )

Prints the location submission form.

em_locations_admin()​

em_locations_admin( $args = array() )

Prints a table of the logged-in user's locations, with links to add and edit them. The user needs the edit_locations capability. Everyone else sees "You must log in to view and manage your locations."

ParameterTypeDefaultDescription
$argsarrayarray()Optional. event_archetype, as above.

em_bookings_admin()​

em_bookings_admin()

Prints the bookings management screen for the logged-in user's events. The user needs the manage_bookings capability. Everyone else sees "You must log in to view and manage your bookings."

em_my_bookings()​

em_my_bookings()

Prints the list of bookings the logged-in visitor has made, as on the My Bookings page.

Conditional tags​

These return true or false and print nothing. Use them in if statements.

<?php if ( em_is_event_page() ) : ?>
<p class="notice">Doors open 30 minutes before the start time.</p>
<?php endif; ?>

em_is_event()​

em_is_event( $data, $object_required = false )

Whether $data is an event.

ParameterTypeDefaultDescription
$datamixedrequiredA post ID, a WP_Post, an EM_Event, or a post type name.
$object_requiredboolfalsetrue accepts only an EM_Event object.

em_is_location()​

em_is_location( $data, $object_required = false )

Whether $data is a location.

ParameterTypeDefaultDescription
$datamixedrequiredA post ID, a WP_Post, an EM_Location, or a post type name.
$object_requiredboolfalsetrue accepts only an EM_Location object.

em_are_events_available()​

em_are_events_available( $scope = 'future' )

Whether at least one event exists within $scope.

ParameterTypeDefaultDescription
$scopestring'future'Any scope value.

Page tests​

Each of these tests the page being displayed.

FunctionReturns true on
em_is_events_page() The events page.
em_is_event_page() A single event page.
em_is_calendar_day_page() The page listing one day's events, reached from a calendar.
em_is_category_page( $category = false ) A single category page. Pass a term ID, a slug, or an array of them to test for particular categories.
em_is_categories_page() The categories list page.
em_is_tag_page( $tag = false ) A single tag page. Pass a term ID, a slug, or an array of them to test for particular tags.
em_is_location_page() A single location page.
em_is_locations_page() The locations list page.
em_is_my_bookings_page() The My Bookings page.
em_is_event_rsvpable() A single event page for an event with bookings enabled.