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 - List upcoming events from The Events Calendar
 * @link https://displayposts.com/2019/01/04/display-upcoming-events-from-the-events-calendar/
 */
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 );

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk