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.
<?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_forem_get_:em_events()prints,em_get_events()returns. - Arguments.
$argsis 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_headerorformat_footer. See format parameters. - Underlying classes. The tags are thin wrappers.
em_get_calendar()returnsEM_Calendar::output(), and the list functions end up inEM_Events::output()andEM_Locations::output(). All are defined inem-template-tags.phpin the plugin folder.
Lists and calendars
em_events()
em_events( $args = array() )
Prints a list of events.
| Parameter | Type | Default | Description |
|---|---|---|---|
$args | array or string | array() | 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
$args | array or string | array() | General and location search parameters. |
em_locations( array( 'country' => 'US', 'eventful' => 1 ) );
em_calendar()
em_calendar( $args = array() )
Prints a calendar of events.
| Parameter | Type | Default | Description |
|---|---|---|---|
$args | array or string | array() | 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
$args | array or string | array() | 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' ) );
Links
em_link()
em_link( $text = '' )
Prints a link to the events page.
| Parameter | Type | Default | Description |
|---|---|---|---|
$text | string | '' | The link text. When empty, the title of the events page is used. |
em_rss_link()
em_rss_link( $text = 'RSS' )
Prints a link to the RSS feed of events.
| Parameter | Type | Default | Description |
|---|---|---|---|
$text | string | 'RSS' | The link text. |
Search forms
em_event_search_form()
em_event_search_form( $args = array() )
Prints the events search form.
| Parameter | Type | Default | Description |
|---|---|---|---|
$args | array | array() | Search form parameters. |
em_location_search_form()
em_location_search_form( $args = array() )
Prints the locations search form.
| Parameter | Type | Default | Description |
|---|---|---|---|
$args | array | array() | 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
$args | array | array() | 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."
| Parameter | Type | Default | Description |
|---|---|---|---|
$args | array | array() | 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."
| Parameter | Type | Default | Description |
|---|---|---|---|
$args | array | array() | 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
$data | mixed | required | A post ID, a WP_Post, an EM_Event, or a post type name. |
$object_required | bool | false | true accepts only an EM_Event object. |
em_is_location()
em_is_location( $data, $object_required = false )
Whether $data is a location.
| Parameter | Type | Default | Description |
|---|---|---|---|
$data | mixed | required | A post ID, a WP_Post, an EM_Location, or a post type name. |
$object_required | bool | false | true accepts only an EM_Location object. |
em_are_events_available()
em_are_events_available( $scope = 'future' )
Whether at least one event exists within $scope.
| Parameter | Type | Default | Description |
|---|---|---|---|
$scope | string | 'future' | Any scope value. |
Page tests
Each of these tests the page being displayed.