Skip to content

Instantly share code, notes, and snippets.

@cstrouse
Created August 23, 2020 17:22
Show Gist options
  • Save cstrouse/6f168fc15d8a7b3a876aac451417ee45 to your computer and use it in GitHub Desktop.
Save cstrouse/6f168fc15d8a7b3a876aac451417ee45 to your computer and use it in GitHub Desktop.
Exclude the current post on an archive page (useful especially when using the repeater with Oxygen)
function cst_exclude_current_post_from_archive( $query ) {
if ( ! is_admin() ) {
$query->set('post__not_in', array( get_the_ID() ) );
}
}
add_action( 'pre_get_posts', 'cst_exclude_current_post_from_archive' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment