Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Hide pages from search results
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