SHOW:
|
|
- or go back to the newest paste.
| 1 | add_filter('tribe_events_pre_get_posts', 'filter_tribe_all_occurences', 100);
| |
| 2 | ||
| 3 | function filter_tribe_all_occurences ($wp_query) {
| |
| 4 | ||
| 5 | - | $te = TribeEvents::instance(); |
| 5 | + | if ( !is_admin() ) {
|
| 6 | ||
| 7 | - | if($te->displaying == 'all') {
|
| 7 | + | |
| 8 | $today = new DateTime(); | |
| 9 | ||
| 10 | // Join with existing meta_query | |
| 11 | if(is_array($wp_query->meta_query)) | |
| 12 | $new_meta = $wp_query->meta_query; | |
| 13 | ||
| 14 | // Add new meta_query, select events ending from now forward | |
| 15 | $new_meta[] = array( | |
| 16 | 'key' => '_EventEndDate', | |
| 17 | 'type' => 'DATETIME', | |
| 18 | 'compare' => '>=', | |
| 19 | 'value' => $today->format('Y-m-d H:i:s')
| |
| 20 | ); | |
| 21 | ||
| 22 | $wp_query->set( 'meta_query', $new_meta ); | |
| 23 | } | |
| 24 | ||
| 25 | return $wp_query; | |
| 26 | } |