Created
August 15, 2020 21:40
-
-
Save wpexplorer/6c84356b72ebf3716942a07991e78b3b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
add_action( 'pre_get_posts', function( $query ) { | |
if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { | |
$excluded_pages = array( 'PAGE_1_ID', 'PAGE_2_ID' ); | |
set_query_var( 'post__not_in', $excluded_pages ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment