Created
August 23, 2020 17:22
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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