Exclude Certain Search Results From No Index

#412260
  • Hello. Thank you for your plugin. As a rule, I know it is best to set search result pages as “no index”. However, there are a handful of search results that I would like to have set to “index”. Is there anyway that under “SEO Titles & Meta” => “Misc Pages” => “Noindex Search Results”, you can add an “Exclude” box for specific search result URLs I want to exclude from the noindex? Or maybe tell me another way I can make only certain search result URLs “index”.

    EXAMPLE: My Collectibles Store sells a lot of items that are “limited editions” which are listed throughout several different product categories. I would like the search engines to have a page(s) where all the limited editions are grouped together. The best way for this to happen (since I don’t want to create an actual “page” to accomplish this) is for them to have the limited editions search result:

    https://collectiblesandmoreinstore.com/shop/?product_cat=&post_type=product&s=limited+edition

    Can you please assist me with this? Thank you for your time.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I just thought of a possible solution. I can add “allow” for the specific url to my robots.txt file right?

    Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    Unfortunately, we don’t have an option to exclude some of the search results pages if that option is enabled.

    However, you can use and customize this filter to set the limited edition search results on your site to index:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
      $url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
      if(strpos($url, 's=limited+edition')) {
        $robots["noindex"] = 'index';
        $robots["nofollow"] = 'follow';
      }
      return $robots;
    });

    The filter should be added to your active theme’s functions.php file. Here’s another way to apply the filter using the rankmath.php file:
    https://rankmath.com/kb/filters-hooks-api-developer/#adding-filters-and-hooks-in-rank-math-php

    I hope that helps.

    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

The ticket ‘Exclude Certain Search Results From No Index’ is closed to new replies.