Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created November 4, 2015 14:18
Show Gist options
  • Save jchristopher/860773ab46e89a0e862a to your computer and use it in GitHub Desktop.
Save jchristopher/860773ab46e89a0e862a to your computer and use it in GitHub Desktop.
<?php
function my_find_expired_events( $ids ) {
$args = array(
'post_type' => 'tribe_events',
'nopaging' => true,
'fields' => 'ids',
'meta_query' => array(
array(
'key' => '_EventEndDate',
'value' => date( 'Y-m-d H:i:s' ),
'compare' => '<',
'type' => 'DATETIME',
),
),
);
$expired_events = get_posts( $args );
$ids = array_merge( $ids, $expired_events );
$ids = array_map( 'absint', $ids );
$ids = array_unique( $ids );
return $ids;
}
add_filter( 'searchwp_exclude', 'my_find_expired_events' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment