How to disable wp-sitemap.xml in WordPress

Sitemaps in WordPress 5.5

By default, WordPress 5.5 includes an extensible core sitemap to help search engines find your most important pages. This sitemap can be created for all queryable post types, taxonomies, author archives, and homepage.

WordPress will expose a sitemap index, which can hold up to 50000 sitemaps while a single one can hold a (filterable) at least 2000 entries, at /wp-sitemap.xml. Search engines can easily read this sitemap thanks to the robots.txt file exposed by WordPress.

You can configure sitemaps behavior by following this instruction from the WordPress developer team.

Disable XML Sitemaps Using Code

In case you don’t like using a plugin, you have two options to work with code: quickly disable or totally remove WordPress 5.5 default XML sitemaps.

To quickly disable WordPress 5.5 default XML sitemap, insert the following code to the theme’s functions.php file:

add_filter( 'wp_sitemaps_enabled', '__return_false' );

But that way just hides the XML sitemap and still keeps all the functions. To permanently remove WordPress XML sitemaps functionality completely, insert this code in the functions.php file of your theme:

add_action( 'init', function() {
remove_action( 'init', 'wp_sitemaps_get_server' );
}, 5 );

Final Words

Now you know the quick and easy ways to disable XML sitemaps in WordPress 5.5. Depending on your website and your demand, you may decide to keep or remove this feature. For example, if you haven’t added sitemaps yet, you should keep the WordPress default sitemaps.

This version has many other features and I think users will need time to explore and test all of them. If you have any experience with this version or any question about it, feel free to share it with us.

Last Update on:March 5th, 2023 at 5:19 pm

Limit Login Attempts in WordPress Without a Plugin
Previous post