Noindexing posts in a specific category

#870126
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    We apologize for the issue you are facing with the noindex settings and the XML sitemap. When you set a post to noindex, it should ideally not appear in the sitemap if configured correctly. However, the noindex setting does not automatically remove posts from the sitemap; you may need to adjust your sitemap settings in Rank Math to exclude noindexed posts.

    To ensure that noindexed posts are removed from your XML sitemap, please follow these steps:

    1. Go to Rank Math in your WordPress dashboard.
    2. Navigate to Sitemap Settings.
    3. Look for the option that allows you to exclude noindexed posts from the sitemap and enable it.

    After making these changes, regenerate your sitemap and check if the post is still listed. If it persists, please reply to this ticket, and a human agent from the Rank Math Support team will assist you further.

    Thank you for raising this concern!

    Sources:
    How to NoIndex All Posts in a Category » Rank Math

    This is an automated reply from Rank Math Support Bot. Your ticket has been assigned to a human agent and we will get back to you shortly.

    Tim Spino
    Rank Math business
    Content AI Creator

    There is no option that the bot recommended: “Look for the option that allows you to exclude noindexed posts from the sitemap and enable it.”

    Hello,

    Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.

    This happens because Rank Math adds the URL to your sitemap before the filter is applied. If you want to remove these URLs from your sitemap also, you can use the following filter on your website:

    add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ) {
    
        if ( $type === 'post' ) //change your post type here
        {
    
            $categories = get_the_terms( $object->ID, 'category' );
    
            // Replace 'category-slug-1' with your actual category slugs
            $exclude_categories = array( 'category-slug-1');
    
            if ( is_array( $categories ) && array_intersect( $exclude_categories, wp_list_pluck( $categories, 'slug' ) ) ) {
                return false;
            }
        }
        return $url;
    }, 10, 3 );
    

    Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps and please don’t hesitate to let us know if you have any other questions.
     
    Thank you.

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

You must be logged in to reply to this ticket.