Display functions (template-tags) for use in WordPress templates.
Table Of Contents
HTML After Event (Display)
tribe_events_after_html()
Display HTML to output after the event template. This is whatever is set in Settings > The Events Calendar > Template.
Returns
- void
More Info
- since: 2.0
Examples
<?php tribe_events_after_html(); ?>
HTML Before Event (Display)
tribe_events_before_html()
Display HTML to output before the event template. This is whatever is set in Settings > The Events Calendar > Template.
Returns
- void
More Info
- since: 2.0
Examples
<?php tribe_events_before_html(); ?>
All Day Event Test
tribe_get_all_day([int $postId = null])
Returns true if the event is an all day event.
Parameters
- int
$postId: (optional)
Returns
- bool
More Info
- since: 2.0
Examples
<?php if(tribe_get_all_day()) {
echo '<div>this event is all day!</div>';
} ?>
Event Cost
tribe_get_cost([int $postId = null])
Returns the cost of an event. If EventBrite plugin is active:
- If the event is registered in eventbrite, and has one ticket. Return the cost of that ticket.
- If the event is not registered in eventbrite, and there is meta, return that.
- If the event is not registered in eventbrite, and there is no meta, return “”
Parameters
- int
$postId: (optional)
Returns
- string
More Info
- return: Cost of the event.
Examples
<?php echo tribe_get_cost(); ?>
Current Template
tribe_get_current_template()
Get the current page template that we are on. This will return the full server path to the template.
Returns
- string
More Info
- return: Page template
- todo: Update the function name to ensure there are no namespace conflicts.
- since: 2.0
Examples
<?php echo tribe_get_current_template(); ?>
Get Event
tribe_get_events([array $args = ''])
Queries the events using WordPress get_posts() by setting the post type and sorting by event date.
Parameters
- array
$args: query vars with added defaults including post_type of events, sorted (orderby) by event date (order) ascending
Returns
- array
Examples
This example demonstrates using tribe_get_events() to query all events and display an unlimited number of events per page.
<?php
global $post;
$all_events = tribe_get_events(array(
'eventDisplay'=>'all',
'posts_per_page'=>-1
));
foreach($all_events as $post) {
setup_postdata($post);
?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php if ( has_post_thumbnail() ) { ?>
<div class="event-thumb">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
</div>
<div class="event-excerpt">
<?php the_excerpt(); ?>
</div>
<?php } else { ?>
<div class="event-content">
<?php the_content(); ?>
</div>
<?php } ?>
<?php } //endforeach ?>
<?php wp_reset_query(); ?>
Here’s an example using a date range from today’s date through the next 30 days:
<?php
global $post;
$current_date = date('j M Y');
$end_date = date('j M Y', strtotime('30 days'));
$get_posts = tribe_get_events(array('start_date'=>$current_date,'end_date'=>$end_date,'posts_per_page'=>10) );
foreach($get_posts as $post) { setup_postdata($post); ?>
<div class="post">
<h4 class="post-header"><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h4>
<span class="event-date"><a href="<?php the_permalink(); ?>"><?php echo tribe_get_start_date($post->ID, true, 'M j, Y'); ?></a></span>
<div class="post-content"><?php the_content(); ?></div>
</div>
<?php } //endforeach ?>
<?php wp_reset_query(); ?>
Here’s an example querying for a specific events category and only upcoming events:
<ul>
<?php
global $post;
$all_events = tribe_get_events(
array(
'eventDisplay'=>'upcoming',
'posts_per_page'=>10,
'tax_query'=> array(
array(
'taxonomy' => 'tribe_events_cat',
'field' => 'slug',
'terms' => 'conferences'
)
)
)
);
foreach($all_events as $post) {
setup_postdata($post);
?>
<li>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<span class="event-date"><a href="<?php the_permalink(); ?>"><?php echo tribe_get_start_date($post->ID, true, 'M j, Y'); ?></a></span>
<?php if ( has_post_thumbnail() ) { ?>
<div class="event-thumb">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
</div>
<div class="event-excerpt">
<?php the_excerpt(); ?>
</div>
<?php } else { ?>
<div class="event-content">
<?php the_content(); ?>
</div>
<?php } ?>
</li>
<?php } //endforeach ?>
<?php wp_reset_query(); ?>
</ul>
Here’s an example of getting events for one specific Venue (you’ll want to substitute your own Venue ID):
<?php
global $post;
$get_posts = tribe_get_events(array('posts_per_page'=>10, 'venue'=>176) );
foreach($get_posts as $post) { setup_postdata($post); ?>
<div class="post">
<h4 class="post-header"><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h4>
<span class="event-date"><a href="<?php the_permalink(); ?>"><?php echo tribe_get_start_date($post->ID, true, 'M j, Y'); ?></a></span>
<div class="post-content"><?php the_content(); ?></div>
</div>
<?php } //endforeach ?>
<?php wp_reset_query(); ?>
More Info
- return: List of posts.
- see: get_posts()
- link: http://codex.wordpress.org/Template_Tags/get_posts
- link: http://codex.wordpress.org/Function_Reference/get_post
- since: 2.0
- uses: get_posts()
- valid eventDisplay options: ‘past’, ‘upcoming’, ‘day’, ‘all’, ‘month’
Event Post Meta
tribe_get_event_meta([int $postId = null], [string $meta = false], [bool $single = true])
Get event post meta.
Parameters
- int
$postId: (optional) - string
$meta: name of the meta_key - bool
$single: determines if the results should be a single item or an array of items.
Returns
- mixed
More Info
- return: meta value(s)
- since: 2.0
Get Options
tribe_get_option(string $optionName, [string $default = ''])
Retrieve specific key from options array, optionally provide a default return value.
Parameters
- string
$optionName: Name of the option to retrieve. - string
$default: Value to return if no such option is found.
Returns
- mixed
More Info
- return: Value of the option if found.
- todo: Abstract this function out of template tags or otherwise secure it from other namespace conflicts.
- since: 2.0
Event Type Test
tribe_is_event([int $postId = null])
Checks type of $postId to determine if it is an Event.
Parameters
- int
$postId: (optional)
Returns
- bool
More Info
- return: true if this post is an Event post type
- since: 2.0
Examples
<?php if(tribe_is_event()) {
echo '<div>this is an event post type!</div>';
} ?>
Multi-day Event Test
tribe_is_multiday([int $postId = null])
Returns true if the event spans multiple days.
Parameters
- int
$postId: (optional)
Returns
- bool
More Info
- return: true if event spans multiple days
- since: 2.0
Examples
<?php if(tribe_is_multiday()) {
echo '<div>this is a multi day event !</div>';
} ?>
Venue Type Test
tribe_is_venue([int $postId = null])
Checks type of $postId to determine if it is a Venue.
Parameters
- int
$postId: (optional)
Returns
- bool
More Info
- return: True if post type id Venue
- since: 2.0
Examples
<?php if(tribe_is_venue()) {
echo '<div>this is a venue post type!</div>';
} ?>
Event Category Name
tribe_meta_event_category_name()
Return the current event category name based on the url.
Returns
- string
More Info
- return: Name of the Event Category
- since: 2.0
Examples
<?php echo tribe_meta_event_category_name(); ?>
Event Categories (Display)
tribe_meta_event_cats([string $label = null], [string $separator = ', '])
Display the event categories with the label wrapped in a <dt> tag and the categories in <dd> tags.
Parameters
- string
$label - string
$separator
Returns
- void
More Info
- since: 2.0
- uses: the_terms()
Examples
<?php tribe_meta_event_cats(); ?>
