Hello,
We apologize for the issue you are facing with including custom query strings in your sitemap. Currently, there isn’t a direct setting in Rank Math to add query strings to the sitemap for product pages or categories. However, you can achieve this by using a custom filter in your theme’s functions.php file.
Here’s how you can add the custom query strings for your products:
- Open your theme’s
functions.php file.
- Add the following code snippet:
/**
* Filter to add extra URLs to the XML sitemap by type.
* Only runs for the first page, not on all.
* @param string $content String content to add, defaults to empty.
*/
add_action( 'rank_math/sitemap/product_content', function() {
return '
https://rankmath.com/wp-content/uploads/2021/02/include-in-sitemap-2.jpg
2020-06-10T20:20:20+00:00
';
});
- Replace `https://rankmath.com/wp-content/uploads/2021/02/include-in-sitemap-2.jpg with the actual URL of your product pages and repeat this for each currency you want to include.
This will allow you to manually add the URLs with the query strings to your sitemap.
For more detailed guidance on configuring sitemaps, you can refer to our knowledgebase article.
If you have further questions or need assistance with this implementation, 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!
Hi Support
How do I do this if I want to include for all products? Because adding this code individually seems very heavy under the function.php file
Hello,
Unfortunately, you may need to use the filter to add the parametered URLs to the sitemap as Rank Math does not support adding those.
However, you may customize the filter to apply them to all your products without including all the URLs in the sitemap, but it is already out of our scope of support.
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.