Hello,
We apologize for the issue you are facing with your product category sitemap. It seems that Rank Math is generating multiple sitemap files for your product categories, which can happen due to the way the URLs are structured or how many categories you have.
Here are a few things to consider:
- Sitemap Limit: Even though you have set a limit of 350 links per sitemap, Rank Math may still create multiple sitemap files if the total number of product categories exceeds this limit or if there are other factors affecting the generation.
- 404 Error: The 404 error in
product_cat-sitemap2.xml could indicate that there are no valid product categories to display in that particular sitemap file. This might happen if there are empty categories or if there was an issue during the sitemap generation process.
- Configuration Check: Ensure that all your product categories are properly configured and that there are no restrictions in your settings that might prevent them from being included in the sitemap.
To troubleshoot further, you can:
- Check your product categories in WooCommerce to ensure they are all set up correctly and not empty.
- Review any potential plugin conflicts that might affect sitemap generation.
- Clear any caching plugins you might be using to ensure the latest sitemap is generated.
If the issue persists, we recommend replying to this ticket, and a human agent from the Rank Math Support team will assist you further.
Thank you for raising this concern!
Sources:
Rank Math Sitemap Issues and Their Fixes Ā» Rank Math
Hello,
Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.
Can you please try to follow the steps below and see if that works for you?
1. Flush the Sitemap cache by following this video screencast:
https://i.rankmath.com/pipRDp
2. Exclude the Sitemap files of the Rank Math plugin in your caching plugin. The cache could be via a plugin or from the server. For plugins or Cloudflare, please follow this article:
https://rankmath.com/kb/exclude-sitemaps-from-caching/
3. If the above steps donāt seem to work, kindly apply the following filter to your site.
add_filter( 'rank_math/sitemap/enable_caching', '__return_false');
Hereās how you can add filter/hook to your WordPress site:
https://rankmath.com/kb/wordpress-hooks-actions-filters/
Let us know how it goes. Looking forward to helping you.
Thank you.
Hi,
thank you for reaching out.
I have tried the steps, nothing worked.
I have found out the Sitemap generation is in coflict with this part of code
//Rank Math SEO - remove category "RƓzne" and all its subcategories
function exclude_product_category_from_sitemap( $url, $type, $object ) {
// Check if the object is a product category
if ( 'term' === $type && 'product_cat' === $object->taxonomy ) {
$excluded_category = 2136; // ID of the category to exclude
// Check if the current term is the excluded category or a child of it
if ( $object->term_id == $excluded_category || term_is_ancestor_of( $excluded_category, $object->term_id, 'product_cat' ) ) {
return false; // Exclude from sitemap
}
}
return $url;
}
add_filter( 'rank_math/sitemap/entry', 'exclude_product_category_from_sitemap', 10, 3 );
from this forum: https://support.rankmath.com/ticket/remove-product-category-and-all-its-subcategories-from-sitemap/?_gl=1*1mv7gor*_gcl_au*MzE0NTc4NzQ0LjE3MTgwOTIyODQ.*_ga*MjEwMTM3NTk5MS4xNzA4OTQyOTk1*_ga_WTF2SQ5LGQ*MTcyNDE0MTM2MC4yMi4xLjE3MjQxNDE0NDYuMzQuMC4w
Beacuse I want to exclude some product category and all its subcategories from Sitemap – which the above code does. But at the same time, the Sitemap behaves and generates as much .xmls as if the excluded product category with subcategories was not excluded.
Hence some of .xml returns 404 – because when I remove the above code they contain only product categories from excluded list.
Could the code and sitemap be adjusted somehow so this bug wont appear?
Thank you very much.
Kind regards
Hello,
That code runs after the initial generation calculates how many sub-sitemaps should be added to the main sitemap so this issue arises.
The only way around this would be to increase the number of URLs per sitemap until there’s only one product category sitemap, however, that would always need to be adjusted if that number changes in the future.
Don’t hesitate to get in touch if you have any other questions.
Thank you very much, to increase the number of URLs per sitemap really fixed the bug.
Marking as solved.
Kind regards,
Hello,
We are glad that helped.
Please feel free to reach out to us again in case you need any other assistance.
We are here to help.
Thank you.