12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Aug 20, 2020

How to Disable WP Sitemap Generation for Oxygen Templates

Sridhar Katakam

One of the new features introduced in WordPress 5.5 is XML Sitemaps Functionality.

By default, XML sitemaps get generated for all post types, taxonomies and users. It does not make sense to have Oxygen Templates be included in the sitemaps at a URL like https://example.com/wp-sitemap-posts-ct_template-1.xml since these templates are not meant to be public-facing.

Clicking on the .xml link shows the list of templates like this:

Here’s how we can tell WordPress to disable the XML sitemaps for Oxygen Templates:

Install and activate Code Snippets plugin.

Go to Snippets > Add New.

Title: Disable WP Sitemap Generation for Oxygen Templates

Code:

add_filter(
    'wp_sitemaps_post_types',
    function( $post_types ) {
        unset( $post_types['ct_template'] );
        return $post_types;
    }
);

Set the snippet to run everywhere. Save changes and activate.

That’s it.

If you wish to disable the XML sitemaps for multiple post types, simply add them in new lines in the unset() like so:

add_filter(
	'wp_sitemaps_post_types',
	function( $post_types ) {
		unset( $post_types['ct_template'] );
		unset( $post_types['surl'] );
		return $post_types;
	}
);

and to totally disable the WordPress XML sitemaps, use this code snippet:

add_filter( 'wp_sitemaps_enabled', '__return_false' );
tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-down