Created
April 27, 2015 03:13
-
-
Save dryan1144/244fb09c0d1008f85b1e to your computer and use it in GitHub Desktop.
Hide pages from search results
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
<?php | |
add_filter('pre_get_posts','your_custom_search_filter'); | |
function your_custom_search_filter($query) { | |
if (!is_admin() && $query->is_search) { | |
$exclude_ids = array(1,2,3); //page ids you want to exclude | |
$query->set('post__not_in', $exclude_ids); | |
} | |
return $query; | |
} ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment