• Hello

    Like most wordpress themes mine has a search bar from where people can search my pages.

    There are a couple of pages that have private information that I want to hide.

    How to exclude a page from being found in in site search?

    Thanks

Viewing 1 replies (of 1 total)
  • Moderator t-p

    (@t-p)

    Try placing this snippet in your theme’s functions.php file:

    // search filter
    function my_search_filter($query) {
       if ($query->is_search) {
          $query->set('post__in',array(1,2,3));
       }
       return $query;
    }
    add_filter('pre_get_posts','my_search_filter');

    where, 1,2,3 are the page IDs you want excluded. Change it to your actual ID.

Viewing 1 replies (of 1 total)
  • The topic ‘How to exclude a page from being found in in site search’ is closed to new replies.