Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created December 14, 2016 19:31
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 joshfeck/31c5055be20e5e4dfaf333ab7a4090e9 to your computer and use it in GitHub Desktop.
Save joshfeck/31c5055be20e5e4dfaf333ab7a4090e9 to your computer and use it in GitHub Desktop.
Filter out specific posts (including EE4 events) from displaying on post archives. https://eventespresso.com/topic/removing-date-and-time-information-from-specific-events/#post-225500
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function ee_filter_pre_get_posts( $query ) {
if ( ! is_singular() && $query->is_main_query() ) {
$query->set( 'post__not_in', array( 148, 242 ) );
}
}
add_action( 'pre_get_posts', 'ee_filter_pre_get_posts' );

Usage notes

You can add the above to a functions plugin or into your WordPress theme's functions.php file.

Change the array( 148, 242 ) to match the post IDs of the events you want to hide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment