Skip to content

Instantly share code, notes, and snippets.

@Pebblo Pebblo/example.php Secret
Last active May 31, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.