Created
          April 21, 2017 04:08 
        
      - 
      
- 
        Save vicskf/490fc3ff0c8f63e255ff2fbbfa8ae963 to your computer and use it in GitHub Desktop. 
    Does not show past events from The Events Calendar
  
        
  
    
      This file contains hidden or 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 | |
| /* | |
| * Does not show past events from The Events Calendar | |
| */ | |
| add_filter('tribe_events_pre_get_posts', 'filter_tribe_all_occurences', 100); | |
| function filter_tribe_all_occurences ($wp_query) { | |
| if ( !is_admin() ) { | |
| $new_meta = array(); | |
| $today = new DateTime(); | |
| // Join with existing meta_query | |
| if(is_array($wp_query->meta_query)) | |
| $new_meta = $wp_query->meta_query; | |
| // Add new meta_query, select events ending from now forward | |
| $new_meta[] = array( | |
| 'key' => '_EventEndDate', | |
| 'type' => 'DATETIME', | |
| 'compare' => '>=', | |
| 'value' => $today->format('Y-m-d H:i:s') | |
| ); | |
| $wp_query->set( 'meta_query', $new_meta ); | |
| } | |
| return $wp_query; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment