-
-
Save billerickson/2a1c2c4ee4d622f4633048529ceb8931 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Display Posts - List upcoming events from The Events Calendar | |
* @see 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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@carljbusch
I know this is late, but this might still be helpful for others.
I use the following (or similar) for that sort of thing: https://gist.github.com/KZeni/1c9d2204f553457a8b034696d4e472ec