Written by me@grafxflow
18 Mar, 2013
0
2,251
If you want to hide certain pages or posts from the WordPress search results. Then you need to edit the functions.php file.
At first open the file and add this function. In the array you need to add the relevant post or page id number to the array. So for example below 1,5 and 10.
function SearchExcludeFilter($query) {
if ($query->is_search) {
$query->set('post__not_in', array(1,5,10));
}
return $query;
}
add_filter('pre_get_posts','SearchExcludeFilter');
30 Apr, 2017
11 Mar, 2013
11 Mar, 2013
I am a Full-stack Developer who also started delving into the world of UX/UI Design a few years back. I blog and tweet to hopefully share a little bit of knowledge that can help others around the web. Thanks for stopping by!
Follow11 Jul, 2023
21 Jun, 2023
Views: 168,243
Views: 41,249
Views: 38,818
Views: 35,833