How to remove, replace and customize WordPress native XML sitemaps

As you may know, since version 5.5, WordPress incorporates the native XML sitemaps functionality. This way, from you will see the sitemap of your web contents.

The WordPress native sitemaps are quite complete, but basic. They incorporate all the taxonomies (tags, categories) and content types (entries, pages, custom) and users, they don’t allow much customization, but something can be done.

You might want to keep using the more customizable sitemap you already had with your SEO plugin, right?

But before we get to that, we’re going to give the native WordPress XML sitemaps a try too.

To do this we’re going to see how to disable and customize the native WordPress XML sitemaps, and even how to replace them with better, more customizable ones.

Let’s do it!

Disable native WordPress XML sitemaps completely

The same WordPress documentation offers us 2 methods to completely disable your native XML sitemaps.

The first method would be to add the following filter to your customization plugin:

add_filter('wp_sitemaps_enabled', '__return_false');Code language: JavaScript (javascript)

Or, if you prefer, by an action:

remove_action( 'init', 'wp_sitemaps_get_server' );Code language: JavaScript (javascript)

In both cases you completely disable WordPress’ native XML sitemapping feature.

Another method of completely removing the native WordPress XML sitemaps would be through a plugin, like this one…

You only have to install it and activate it, it only has one line of code, the one from the filter we have seen in the first trick above.

Selectively disable native WordPress XML site maps

However, if you prefer to disable only the creation of parts of the sitemap there are several functions you can use.

Remove pages, entries or custom content types from the native XML sitemap

If, for example, you want the custom content types project not to be added to your native WordPress XML sitemap you can add this feature to your utility plugin:

//Remove CPT project from WP sitemap
	function( $post_types ) {
		unset( $post_types['project'] );
		return $post_types;
);Code language: PHP (php)

You can remove from the sitemap any other type of content such as entries (post), pages (page), products (product), etc, by modifying, changing or adding $post_types based on the above code.

Remove taxonomies from the native XML sitemap

Similarly, you can remove taxonomies from the sitemap, with a function like the following:

//Remove taxonomies from WP sitemap
	function( $taxonomies ) {
		unset( $taxonomies['post_tag'] );
		return $taxonomies;
);Code language: PHP (php)

In this example we remove the tags from the entries (post_tag) but you can use it to remove the categories or any other taxonomy.

Remove specific elements from the native XML site map

Another situation would be when you want to remove specific elements (contents, taxonomies, etc.) from the sitemap.

Remove content through their ID

For example, you might want the page with ID 21 not to appear in the sitemap. We would do it this way:

//Remove page ID 21 from the WP sitemap
	function( $args ) {
		$args['post__not_in'] = isset( $args['post__not_in'] ) ? $args['post__not_in'] : array();
		$args['post__not_in'][] = 21;
		return $args;
Code language: PHP (php)

Or a category, also by its ID:

//Remove category ID 12 from the WP sitemap
	function( $args ) {
		$args['exclude'] = isset( $args['exclude'] ) ? $args['exclude'] : array();
		$args['exclude'][] = 12;
		return $args;
Code language: PHP (php)

Or even users…

//Remove user ID 1 from the WP sitemap
	function( $args ) {
		$args['exclude'] = isset( $args['exclude'] ) ? $args['exclude'] : array();
		$args['exclude'][] = 1;
		return $args;
);Code language: PHP (php)

How to customize WordPress native XML sitemaps

Before going any further, even making the decision to remove the native WordPress XML sitemaps, you should know that they are not “so” limited, as they allow some additional customizations, besides the possibility we have seen of adding or removing elements.

You can also customize some parameters of the WordPress native XML sitemaps.

By default the native XML sitemap will show the date of publication of your content, but with this feature you can make it show the date of the last modification:

//Date of the last modification in WP sitemap
    function( $entry, $post ) {
        $entry['lastmod'] = $post->post_modified_gmt;
        return $entry;
);Code language: PHP (php)

For this you have the filters wp_sitemaps_posts_entry / wp_sitemaps_users_entry / wp_sitemaps_taxonomies_entry with which to add additional attributes such as changefreq, priority or lastmod, as we have seen in the previous example, to any element of the sitemap.

How to replace WordPress native XML sitemaps with others

If, in view of the above, you consider that the WordPress XML site maps are not enough, then you can choose to use more advanced XML sitemaps, which are usually those offered by WordPress plugins specialized in SEO.

All in One SEO Pack

This veteran SEO plugin for WordPress has recently been updated to omit the native WordPress XML site maps, but I think they’ve made a mistake, and I’ll explain.

It is true that if you have this SEO Plugin, the native WordPress XML sitemap will no longer be available at the usual address ( but for my taste they have been too radical.

Directly that address generates a 404 error, and this situation is not the best, because you can find yourself in the situation that the sitemap was already sent to the Google or Bing search engine console, and this would cause all the errors and problems in the world.

It’s OK to create a redirection from the native XML sitemap URL to the All in One SEO Pack URL ( on your own, but it would have been smarter to apply the strategy that other SEO plugin developers have used.

Rank Math SEO

This is a case of a job well done, because although it takes time because the update to cover this situation came out several days after the WordPress 5.5 update, they have solved the issue well.

So, with the latest version of the plugin, what they have done is to have the sitemap URL of the native WordPress XML site automatically redirect to the sitemap URL that Rank Math creates (

Yoast SEO

Those who best and soonest adapted to this new functionality of the WordPress XML site maps were the people at Yoast SEO, who already a few days before the release of WordPress 5.5 their Plugin was prepared so that there would be no conflicts between the native sitemap and the Plugin’s own.

As they had already done some time ago to avoid 404 errors due to old Plugin XML sitemaps, they included a redirection of the WordPress XML sitemap to the Plugin XML sitemap ( or

This way, it doesn’t matter if you had previously sent the native WordPress sitemap (wp-sitemap.xml) or that of any other SEO Plugin (sitemap.xml) to the GSC, you will never have errors because there is a redirection to the one generated by Yoast SEO.


As I hope you have seen, the sitemaps of the WordPress native XML are not as incomplete as you might think at first, and allow quite a few customizations, although all of them go through the use of hooks.

However, if you prefer to control more the XML sitemaps of your website, and even generate additional XML sitemaps (images, videos, news, etc.) then the most recommended option is to use a SEO plugin like the ones I have mentioned.

Of all of them, the one that offers a more customizable site map is the All in One SEO Pack, but in the rest of the functionalities it is very short compared to Rank Math or Yoast SEO.

Read this post in Spanish: Cómo eliminar, sustituir y personalizar los mapas del sitio XML nativos de WordPress

How useful was this post?

Click on a smiley to rate it!

Average rating 5 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

1 thought on “How to remove, replace and customize WordPress native XML sitemaps”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top