Created
June 19, 2020 13:01
-
-
Save Pebblo/285340c950796e16eae8ba1d2e520513 to your computer and use it in GitHub Desktop.
Exclude sold_out events from EE event lists.
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 if you already have one | |
function tw_ee_tweak_event_list_exclude_sold_out_events_where( $SQL, WP_Query $wp_query ) { | |
if ( isset( $wp_query->query_vars['post_type'] ) && ( $wp_query->query_vars['post_type'] == 'espresso_events' || ( is_array( $wp_query->query_vars['post_type'] ) && in_array( 'espresso_events', $wp_query->query_vars['post_type'] ) ) ) && ! $wp_query->is_singular ) { | |
global $wpdb; | |
$SQL .= "AND {$wpdb->prefix}posts.post_status != 'sold_out' "; | |
} | |
return $SQL; | |
} | |
add_filter( 'posts_where', 'tw_ee_tweak_event_list_exclude_sold_out_events_where', 15, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment