Created
October 17, 2016 18:39
-
-
Save joshfeck/646d496e72942b5251d484d522d762ee to your computer and use it in GitHub Desktop.
Exclude active events from Event Espresso event lists (only show upcoming events). You can add this to a functions or into your WordPress theme's functions.php file.
This file contains 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 | |
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
add_action( 'pre_get_posts', 'my_custom_ee_posts_where_hook' ); | |
function my_custom_ee_posts_where_hook ( $query ) { | |
if ( | |
isset( $query->query_vars['post_type'] ) && | |
( $query->query_vars['post_type'] == 'espresso_events' || | |
( is_array( $query->query_vars['post_type'] ) && | |
in_array( 'espresso_events', $query->query_vars['post_type'] ) ) ) && | |
! $query->is_singular ) | |
{ | |
add_filter( 'posts_where', 'my_custom_ee_posts_where' ); | |
} | |
} | |
function my_custom_ee_posts_where( $SQL ) { | |
$SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start > "' . current_time( 'mysql', true ) . '" '; | |
return $SQL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment