Show upcoming events from The Events Calendar

You can use Display Posts Shortcode to list upcoming events from The Events Calendar.

Add the code below to your theme or core functionality plugin, then display events like this: [display-posts post_type="tribe_events"]

<?php
/**
* Display Posts Shortcode - Only query future events
*
* @author Bill Erickson
* @see
*
* @param array $args
* @param array $atts
* @return array $args
*/
function be_dps_future_events( $args, $atts ) {
// Only run on event queries
if( 'tribe_events' != $args['post_type'] )
return $args;
$args['order'] = 'ASC';
$args['orderby'] = 'meta_value';
$args['meta_key'] = '_EventStartDate';
$args['meta_type'] = 'DATETIME';
$args['meta_query'] = array(
array(
'key' => '_EventStartDate',
'value' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
'compare' => '>'
) );
return $args;
}
add_filter( 'display_posts_shortcode_args', 'be_dps_future_events', 10, 2 );
view raw functions.php hosted with ❤ by GitHub

Display Posts Shortcode