Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active May 31, 2018 14:43
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/24791195c24b868c88ad0ee217906b96 to your computer and use it in GitHub Desktop.
Save Pebblo/24791195c24b868c88ad0ee217906b96 to your computer and use it in GitHub Desktop.
Example of how to exclude specific event ID's from the front end event lists.
<?php //Please do not include the opening PHP tag if you already have one
function tw_ee_exclude_events_from_front_end($wp_query) {
if( is_admin() ){
return;
}
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
) {
$wp_query->set('post__not_in', array(58, 11, 1911));
}
}
add_action('pre_get_posts', 'tw_ee_exclude_events_from_front_end');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment