Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/285340c950796e16eae8ba1d2e520513 to your computer and use it in GitHub Desktop.
Save Pebblo/285340c950796e16eae8ba1d2e520513 to your computer and use it in GitHub Desktop.
Exclude sold_out events from EE event lists.
<?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