Hello,
Thanks for contacting us and sorry for any inconvenience that might have been caused due to that.
If the sitemap is returning a 404 error then it must be being cached by your caching plugin or by a server-side caching. Please follow this guide to exclude the sitemap from cache: https://rankmath.com/kb/exclude-sitemaps-from-caching/
Please don’t hesitate to get in touch in case you need any other assistance.
Hi Jaideep
Yes, I also followed that guide but I keep having problems 🙁
Hello,
The issue occurs due to caching. Please add the filter given below in your theme’s functions.php file to avoid any server-side cache:
add_filter( 'rank_math/sitemap/enable_caching', '__return_false');
Let us know how that goes. Looking forward to helping you.
Thanks.
Excuse my ignorance but I copied your code and pasted it into the functions.php file of the tempalte.
Can you see if I did it right?
The problem is that if I update the tempalte I lose that modification, right?
Hello,
I can check that your sitemap is working fine. If you don’t have a child theme then you can follow this guide to create a new file and avoid losing the changes after updating the theme: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope this helps. Let us know if you need any other assistance.
Thanks.
Perfect, you’re number one.
so I just use that plugin and put the code you gave me and set it to run: Run the snippet everywhere or Active only in the public area?
Hello,
Use the Run the Snippet Everywhere for the snippet settings.
Let us know if you need any other assistance.
Thanks.
Hello,
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.