Skip to content

Instantly share code, notes, and snippets.

@BeardedGinger
Last active September 6, 2016 16:56
Show Gist options
  • Save BeardedGinger/ea60931dd8dae7818465727f090e784f to your computer and use it in GitHub Desktop.
Save BeardedGinger/ea60931dd8dae7818465727f090e784f to your computer and use it in GitHub Desktop.
Filter event list query for The Events Calendar plugin to show events that start 30 days from now
<?php
add_filter( 'tribe_events_list_widget_query_args', 'jm_filter_list_widget_query_args' );
/**
* Filter the query used for the Event List Widget to show only events starting
* in the future
*/
function jm_filter_list_widget_query_args( $args ) {
$offset = 86400 * 30;
$date = date( 'U' ) + $offset;
$args['eventDisplay'] = 'list';
$args['meta_query'] = array(
array(
'key' => '_EventStartDate',
'value' => date( 'Y-m-d H:i:s', $date ),
'compare' => '>=',
'type' => 'DATETIME',
),
);
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment