WordPress 5.5 is bringing a new in-built XML Sitemap feature. This will automatically add an XML file to every WordPress site, with a listing of every page. This helps search engines discover your pages more easily. SEO plugins, such as Yoast SEO, have added this functionality – but now it is in core, so more people can benefit without thinking about it.

There are no new settings in the admin section. The sitemap will be automatically generated so long as the ‘Discourage Sitemaps’ checkbox is unticked.

However, there are some new developer filters to override the behaviours. You can view the changeset to discover these new featured, or you can read on and I highlight some of the key changes.

All these code examples can be placed into your functions.php file, or in a plugin.

Disable WordPress XML Sitemaps

What happens if you want to disable the sitemap? There’s a simple code snippet for it.

add_filter('wp_sitemaps_is_enabled' function($enabled) { return false; }, 10, 1);

Disable WordPress XML Sitemap for Specific Post Type

By default, WordPress will create a sitemap file for each public post type you’ve configured. But what if you want to disable one?

Perhaps you have a Custom Post Type (CPT) with the name ‘clients’. Use this code snippet to disable it:

add_filter('wp_sitemaps_post_types' function($post_types) {
    return $post_types;
}, 10, 1);

Maximum Number of URLs Per Sitemap

By default, sitemaps have 2000 URLs per sitemap. This can be adjusted with this code:

add_filter('wp_sitemaps_max_urls' function($limit) {
    return 100;
}, 10, 1);

Further Filters

There are additional filters, but these three are the key ones I think people will need initially. Further filters can be found by browsing the code, and checking the superseded plugin docs.