18 Mar

WordPress Icon Logo

Hide posts/pages from search results

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;

Posted in: < CMS >
me@grafxflow avatar


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!

Visitors also viewed these posts

Add comment

Add comment