Code to Remove Custom Taxonomies from WordPress Sitemap

/* Remove Custom Taxonomies Sitemap */
function wpflt_disable_custom_taxonomies($taxonomies) {
	unset($taxonomies['actors']); 
	unset($taxonomies['composer']); 
	unset($taxonomies['lyricist']);
	unset($taxonomies['years']);
	unset($taxonomies['genres']);
	return $taxonomies;
}
add_filter('wp_sitemaps_taxonomies', 'wpflt_disable_custom_taxonomies');

If you have created custom taxonomies in WordPress, you may have done it for navigational purposes. If you don’t want these taxonomies to be indexed, use the above code in your theme functions. Ensure you enter the correct slug you used while creating the custom taxonomy.