Exclude certain categories from sitemap and indexing in search engine

  • Hey,
    I want to hinder crawlers from indexing all posts of a certain category. How can I do that?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Thank you for contacting Rank Math today.

    You can add a noindex tag to the page by editing the individual pages and checking the noindex checkbox in Rank math meta box under Advanced tab.
    img

    This will automatically remove the pages from the sitemap.

    We however do not have an option to bulk noindex the pages within a category if that’s your intention. As a work around you can customize the following filter and add it to your theme functions.php file to add the noindex tag to the specified pages:

    /**
     * Allows filtering of the robots meta data.
     *
     * @param array $robots The meta robots directives.
     */
    add_filter( 'rank_math/frontend/robots', function( $robots ) {
         global $post;
         // filter for only a specific category
         if(get_category() == "your_category_name_here"){
            $robots['index'] = "noindex";
            $robots['follow'] = "follow";
            return $robots;
         }
    	return $robots;
    });
    

    Looking forward to helping you. Thank you.

    Sorry, I might havent been clear. I want to bulk exclude posts within a category not pages.
    There is an RSS Feed catcher fetching headlines but I doubt it is good for SEO that these are indexed by Google

    Hello,

    I am sorry if I don’t understand it right but as far as I understand you want to exclude from index all the posts in specific categories and you should be able to achieve exactly that using the code my colleague shared. Is it what you want to achieve?

    Looking forward to help you.

    Yes exactly!

    Hello,

    Then, you should be able to achieve it with the code my colleague shared, what kind of issues did you face using it?

    Looking forward to help you.

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

You must be logged in to reply to this ticket.