id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,focuses 51136,Third-party sitemap plugin returning 404 after disabling core's sitemap,vaurdan,,"When using a third-party sitemap plugin (such as [https://github.com/Automattic/msm-sitemap MSM Sitemap]), sitemaps are returning HTTP status code 404, despite outputting the actual sitemap XML. Core's sitemap is being disabled using the `wp_sitemaps_enabled` filter, however the 404 status code is still being sent in the response. I believe the issue resides in `WP_Sitemaps::init()`, where both the rewrite rules and the template redirect are being set before the actual `$this->sitemaps_enabled()` check ([https://github.com/WordPress/WordPress/blob/5.5/wp-includes/sitemaps/class-wp-sitemaps.php#L65-L72 see here]). Since both Core and `msm-sitemap` use `sitemap` parameter for the rewrite, `WP_Sitemaps::render_sitemaps` will still be called on a `sitemap.xml` request, and since Core sitemap is disabled (`$this->sitemaps_enabled()` is false), it will return a 404 error, despite `msm-sitemap` generating and outputting the correct XML: {{{#!php if ( ! $this->sitemaps_enabled() ) { $wp_query->set_404(); status_header( 404 ); return; } }}} I have came with the following workaround to prevent the 404 status code on sitemap requests: {{{#!php sitemaps_enabled() )` validation to the beginning of the `WP_Sitemaps::init` method. ",defect (bug),new,normal,Awaiting Review,Sitemaps,5.5,normal,,has-patch,,