Exclude category from sitemap Yoast Seo

Yoast recommends this to exclude a category from their sitemap_index.xml but it is not working.

/* Exclude One Taxonomy From Yoast SEO Sitemap */
function sitemap_exclude_taxonomy( $value, $taxonomy ) {
if ( $taxonomy == ‘nameofthecategoryslug’ ) return true;
}
add_filter( ‘wpseo_sitemap_exclude_taxonomy’, ‘sitemap_exclude_taxonomy’, 10, 2
);

I’ve put it in functions.php with the right category, but I can still see the urls in the sitemap.

Is there anything I am doing wrong?

Read more here:: Exclude category from sitemap Yoast Seo

Leave a Reply

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