Exclude Default Category in Sitemap

#667399
  • Resolved Anonymous
    Rank Math free

    If you go to https://pcard.design/post-sitemap.xml you will see posts with a long string of numbers an letters (ex. d5087199-1315-46e3-9048-e7e324fa6a6b). We believe these posts are being generated through the default category. I want to disable in the sitemap but it still shows up. I’ve tried disabling categories and have turned off “index” & checked all the noindex options in the “advanced” field. Screenshot: https://www.screencast.com/t/NEw216hrv44

    What else can we do to not have the default category posts show up on the sitemap? If this cannot be avoided, how can I turn off all posts & add in the posts I want individually?

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

    I apologize for the inconvenience you’re experiencing with excluding the default category posts from your sitemap. I understand that you have already tried disabling categories and using the “index” and “noindex” options in the “advanced” field, but the posts still show up on the sitemap.

    To further troubleshoot this issue, I recommend following these steps:

    1. Double-check the settings in Rank Math SEO: Please navigate to your WordPress Dashboard, then go to Rank Math SEO → Sitemap Settings → Categories. Ensure that the default category is disabled by disabling the “Include in Sitemap” option for the default category. Don’t forget to click on Save Changes after making any modifications.

    2. Clear cache: If you are using a caching plugin or a CDN, clear the cache to ensure that the changes take effect.

    3. Exclude specific posts from the sitemap: If excluding the default category doesn’t work, you can manually exclude individual posts from the sitemap. To do this, go to WordPress Dashboard → Rank Math SEO → Sitemap Settings → General. Scroll down to the “Exclude Posts” section and enter the ID of each post you want to exclude, separated by commas. Remember to click on Save Changes after adding the post IDs.

    If you have followed these steps and the default category posts still appear on the sitemap, please reply to this ticket with the details, and a human agent from our support team will assist you further.

    Thank you for your understanding, and we apologize for any inconvenience caused.

    Best regards,
    RankBot Support

    Sources:
    How to Exclude Content From Sitemap » Rank Math
    How to Configure Sitemaps in Rank Math – Best Settings and Tips

    Hello,

    Thank you for contacting Rank Math support.

    Setting a category to Noindex will exclude it from the sitemap, not the posts assigned. If you want those posts to be excluded from the sitemap, then you will have to set those posts to Noindex or include their IDs in WP Dashboard > Rank Math SEO > Sitemap Settings > General > Exclude Posts.

    Hope that helps, and please do not hesitate to let us know if you need our assistance with anything else.

    Anonymous
    Rank Math free

    Thanks Jaideep. To add to the complexity, we have these specific posts generated via users & then are deleted a week later. Excluding posts won’t help. Is there a webhook / code we can use so that any posts made like this won’t be in the sitemap & won’t be indexed? I noticed that when I look into the post itself it is being indexed. Screenshot: https://www.screencast.com/t/I51c8wEj8

    Hello,

    Can you please confirm if those posts are under a specific category? If so, you can follow this guideline to set all the posts to noindex under a category: https://rankmath.com/kb/how-to-noindex-all-posts-in-a-category/

    In order to remove them from your sitemap, you can use the following filter on your website:

    add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ) {
    
        if ( $type === 'post' ) {
    
            $categories = get_the_terms( $object->ID, 'category' );
    
            // Replace 'category-slug-1', 'category-slug-2', etc. with your actual category slugs
            $exclude_categories = array( 'category-slug-1', 'category-slug-2', 'category-slug-3' );
    
            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/

    This filter will help to remove all the posts under specific categories from your sitemap.

    Hope that helps and please don’t hesitate to let us know if you have any other questions.
     
    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 4 replies - 1 through 4 (of 4 total)

The ticket ‘Exclude Default Category in Sitemap’ is closed to new replies.