How to exclude the main taxonomy page from sitemap ?

[ad_1]

Hello @rstrah,

Thank you for contacting Rank Math support.

Please use the following filter to exclude the URLs from the sitemap:


add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ){
$excluded_urls = [
'https://site.com/blog/',
'https://site.com/case_studies/',
'https://site.com/services/',
'https://site.com/solutions/'
];
$post_url = get_permalink($object->ID);
if ($type === 'post') {
if (in_array($post_url, $excluded_urls)) {
return '';
}
}
return $url;
}, 10, 3 );

Please make sure to flush the Sitemap cache by following this video screencast after adding the filter: https://i.rankmath.com/pipRDp

Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer