In short. Return false through wp_sitemaps_enabled to disable WordPress core XML sitemap output while keeping routes that return HTTP 404.
Definition: WordPress's core XML sitemap output is its built-in set of XML files listing site URLs. As of 17 October 2026, WordPress documents the
wp_sitemaps_enabledfilter as the control for disabling this output while retaining routes that return HTTP 404.
Key facts
- WordPress's core sitemap announcement introduces sitemaps in version 5.5, with the index at
/wp-sitemap.xml. - The
wp_sitemaps_enabledreference specifies that disabling sitemaps retains rewrite rules so requests return 404. - The
sitemaps_enabled()method reads theblog_publicoption before applying the filter. - The
init()implementation skips sitemap registration and the core sitemap callback forrobots.txtwhen sitemaps are disabled during initialization.
What code disables the output?
A filter lets code change a value used by WordPress. The core sitemap announcement supplies this exact line:
add_filter( 'wp_sitemaps_enabled', '__return_false' );
The callback named __return_false makes the filter return false. The same announcement presents this as the method for disabling core sitemaps regardless of the default site visibility setting.
A small custom plugin can hold the line. WordPress's Plugin Basics handbook describes creating a directory under wp-content/plugins, adding a PHP file, and including a plugin header containing at least the plugin name. Following that structure, an example file at wp-content/plugins/disable-core-sitemap/disable-core-sitemap.php contains:
<?php
/**
* Plugin Name: Disable Core Sitemap
*/
add_filter( 'wp_sitemaps_enabled', '__return_false' );
After the file is saved, the plugin appears in the WordPress admin Plugins list. WordPress's plugin management documentation specifies using Activate in the admin Plugins menu for a manually installed plugin.
Why do the sitemap routes remain?
Rewrite rules route a requested address to WordPress's request handler. The wp_sitemaps_enabled documentation explicitly retains those rules when output is disabled, allowing an appropriate 404 response.
The render_sitemaps() implementation checks whether the request is for a sitemap or its stylesheet. If sitemaps are disabled, it marks the query as a 404, sends the 404 status header, and returns before rendering XML. The documented result is a missing-resource response at the core sitemap address.
The init() implementation registers rewrite rules and the rendering callback before checking the enabled state. When that check returns false, initialization stops before registering sitemap providers or adding the sitemap callback to WordPress's robots_txt filter.
How can the disabled state be checked?
The core announcement gives this PHP expression for checking the enabled state within WordPress:
wp_sitemaps_get_server()->sitemaps_enabled()
The sitemaps_enabled() reference specifies a Boolean return value. With the disabling filter in effect, the result is false. A request to /wp-sitemap.xml provides the corresponding HTTP check: the filter reference specifies status 404 for disabled core sitemaps.
Related terms
- XML sitemap
- Where is the built-in WordPress XML sitemap?
- How do I exclude a post type from WordPress core sitemaps?
- robots.txt
FAQ
Can I disable sitemaps through the site visibility setting?
Yes. The core announcement says that discouraging search engines from indexing the site disables sitemaps by default. The wp_sitemaps_enabled filter can override that default behavior.
Does the filter remove the rewrite rules?
The filter reference says the rewrite rules remain to ensure a 404 response. The core sitemap route therefore still has a defined response after disabling output.
Sources
- WordPress, "New XML Sitemaps Functionality in WordPress 5.5", 22 July 2020
- WordPress Developer Resources, "wp_sitemaps_enabled", undated
- WordPress Developer Resources, "WP_Sitemaps::sitemaps_enabled()", undated
- WordPress Developer Resources, "WP_Sitemaps::init()", undated
- WordPress Developer Resources, "WP_Sitemaps::render_sitemaps()", undated
- WordPress Developer Resources, "Plugin Basics", updated 11 March 2026
- WordPress Documentation, "Manage Plugins", updated 10 January 2026
Check how a page reads to answer engines. Open the GEO score analyzer