Tagged: ,

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #121124
    CrystalClear
    Participant

    Hi,
    I have a page that I’ve chosen to be “noindex”, “nofollow”, and not included in the sitemap. However, it still shows up in the internal — and public — search box results for visitors at the site itself if keywords in it are searched for. I’d like to have it entirely excluded from those search results. What is the simplest way to do that?

    Thank you!

    #121134
    Mahesh
    Participant

    @consciousness: For this, you’ll need to create a child theme. You can find more detail on creating child theme HERE. Then in you child theme’s functions.php, and add the following CSS.

    function catchevolution_child_search_filter( $query ) {
      if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) {
        $query->set( 'post__not_in', array( YOUR_PAGE_ID_HERE) );
      }
    }
    add_action( 'pre_get_posts', 'catchevolution_child_search_filter' );

    Note: Please replace “YOUR_PAGE_ID_HERE” in the above code with the id of page you want to remove. If you wish to excluded more that one page, separate it with comma.

    Regards,
    Mahesh

    #121148
    CrystalClear
    Participant

    Thank you. I think I’ll try the plug-in Search Exclude rather than have to make a child theme.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘How I do exclude a "noindex" Page from Search Box results?’ is closed to new replies.