Hello, I’m sorry to hear that you’re experiencing issues with your custom sitemap after enabling Rank Math. It’s definitely possible to use Rank Math with custom post types and have a custom sitemap for them.
If you’re encountering a 404 error with your custom sitemap after enabling Rank Math, there are a few things you can try to resolve the issue. First, ensure that there are no unintended rules in your robots.txt file that might be blocking the sitemap. You can check this by going to Rank Math SEO → General Settings → robots.txt.
Additionally, if you’re using a caching plugin like W3 Total Cache, you may need to create another user agent group and add the ‘googlebot‘ user agent to it. This can help resolve any caching issues that might be causing the 404 error.
If these solutions don’t help, you may need to add some rewrite rules manually to your server configuration. The specific rules will depend on whether you’re using an Apache or Nginx web server. You can find detailed instructions for adding these rewrite rules in the Rank Math knowledge base.
If you’re still facing issues after trying these steps, please feel free to reach out to our support team for further assistance. We’re here to help you 24×7, 365 days a year.
I hope this helps! If you have any further questions or need additional assistance, please don’t hesitate to ask.
Sources:
Rank Math Sitemap Issues and Their Fixes » Rank Math
Using Video Sitemaps in Rank Math
Why the Sitemap_Index.xml is Throwing a 404 Error » Rank Math
I haven’t received any response yet.
Hello,
Thanks for contacting us, and sorry for any inconvenience this might have caused you.
Rank Math can create sitemaps for your custom post types which can be enabled when you head over to WordPress > Rank Math > Sitemap Settings > [Your Post Type] > and enable the toggle “Include in Sitemap” as shown in the image below:

However, ensure that the Robots meta of those custom post type are already set to index on your WordPress dashboard > Rank Math > Titles & Meta > [Post type] > Meta robots:

If this is not so, please share with us if Rank Math can detect the CPT you created and how the CPT was created.
You can also share this guide with your developers to create a custom sitemap compatible with Rank Math: https://rankmath.com/kb/custom-sitemaps/
The sitemap works out of the box with Rank Math Free.
Hope this helps, and please do not hesitate to let us know if you need our assistance with anything else.
Thank you for choosing Rank Math.
Thanks for your response Adetayo. But let me rephrase my question:
We are creating our sitemap with a custom query; the sitemap gets disabled (404) when we enable Rank Math, since the value of those variables becomes empty.
Following are the variables that becomes empty when Rank Math is enabled.
add_filter('query_vars', array($this, 'registerSitemapQueryVars'), 10, 1);
public function registerSitemapQueryVars($vars) {
$vars[] = 'service_sitemap_type';
$vars[] = 'service_type';
$vars[] = 'service_sitemap_number';
return $vars;
}
Hello,
Thank you for your patience.
Upon applying the sitemap filter, you may need to flush the sitemap cache by following these steps:
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. Disable the transient cache for the sitemap by applying this filter. This will make sure that your XML sitemap always reflects the latest changes on your site:
/**
* Filter if XML sitemap transient cache is enabled.
*
* @param boolean $unsigned Enable cache or not, defaults to true
*/
add_filter( 'rank_math/sitemap/enable_caching', '__return_false');
If you’re not sure how to add this code, you can follow this guide:
https://rankmath.com/kb/wordpress-hooks-actions-filters/
Let us know how this goes.
It’s resolved, but your solution did not work.
There is a bug in your code, when we added ‘sitemap’ in the start of our sitemap URL it worked fine but when we were adding the term ‘sitemap’ at the end of the URL it became 404.
But thanks!
Hello,
We are glad to hear that this issue has been resolved. Thank you for letting us know. This ticket will be closed now, but you can always open a new one if you have any other questions or concerns. We are here to help you with anything related to Rank Math.
We appreciate your patience and cooperation throughout this process.
Thank you for choosing Rank Math.