How to remove a taxonomy from the wp-sitemap.xml file

Looking to remove a taxonomy from the wp-sitemap.xml file in WordPress? Here’s a quick and easy guide on how to do this.

Removing a taxonomy from wp-sitemap.xml

In order to remove a taxonomy from wp-sitemap.xml, you’ll have to add the following code inside your funcitons.php file.

function remove_tax_from_sitemap( $taxonomies ) {
     unset( $taxonomies['your_taxonomy'] ); // Replace your_taxonomy with the relevant taxonomy
     return $taxonomies;
}

add_filter( 'wp_sitemaps_taxonomies', 'remove_tax_from_sitemap' );