Hello, I’m sorry to hear that you’re facing difficulties with generating separate sitemaps for products on and not on stock. Currently, Rank Math doesn’t have a built-in feature to generate separate sitemaps for products based on their stock status.
However, you can use custom code to achieve this. You can create a custom sitemap and include only the products that are in stock. Here’s an example of how you can do this:
// Add custom links in get_sitemap_links() function
function custom_get_sitemap_links( $links ) {
// Your logic to get the links for products in stock
return $links;
}
// Add the Code Snippet in Child’s functions.php
add_filter('rank_math/sitemap/providers', function( $external_providers ) {
$external_providers['custom'] = new RankMathSitemapProvidersCustom();
return $external_providers;
});
You can replace the custom_get_sitemap_links
function with your logic to get the links for products in stock. Once done, the new sitemap will show up with your custom links in it.
If you need further assistance with implementing this custom solution, please feel free to reach out to our support team here. We’re here to help!
Sources:
How to Configure Sitemaps in Rank Math – Best Settings and Tips
Remove All Schema from Product Category Pages » Rank Math
How to Create a Custom Sitemap and Include It in Rank Math » Rank Math
Rank Math Sitemap Issues and Their Fixes » Rank Math
Thanks a lot for the quick response!
Just another question. Is there an option that all the products that will be on stock will be places automatically in this sitemap?
We have a lot of product changing day by day.
Hello,
Thank you for your patience.
If a product is set to index, then it will be automatically included in your product sitemaps.
However, in Rank Math PRO, we have the feature to set out-of-stock products as “noindex”.
For that you can set your out-of-stock products to hidden, so Rank Math can set them to noindex and exclude them from your sitemaps.
You can enable this option in Rank Math > General Settings > WooCommerce:
https://rankmath.com/kb/general-settings/#noindex-hidden-products
Looking forward to helping 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.