Exclude certain categories from sitemap and indexing in search engine

#83691
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

    Alberto
    Rank Math business

    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!

    Alberto
    Rank Math business

    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.

    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 5 replies - 1 through 5 (of 5 total)

The ticket ‘Exclude certain categories from sitemap and indexing in search engine’ is closed to new replies.