Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GeoffEW/ef2da29e76f585f1ef8d to your computer and use it in GitHub Desktop.
Save GeoffEW/ef2da29e76f585f1ef8d to your computer and use it in GitHub Desktop.
// Only Display Events with Starting Date from today on //
function start_date_strict($query) {
$post_type = $query->query_vars['post_type'];
// if ($post_type == 'tribe_events') { **ORIGINAL**
if ($post_type == 'tribe_events' && (tribe_is_list_view() || tribe_is_photo() ) ) {
$filterDate = current_time('Y-m-d H:i:s');
if (!empty( $_REQUEST['tribe-bar-date'] ) ) {
$filterDate = $_REQUEST['tribe-bar-date'];
}
$query->query_vars['meta_query'][] =
array( // restrict posts based on meta values
'key' => '_EventStartDate', // which meta to query
'value' => $filterDate, // value for comparison
'compare' => '>=', // method of comparison
'type' => 'DATETIME');
}
}
add_filter( 'tribe_events_pre_get_posts', 'start_date_strict', 100, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment