Hello,
Thank you for contacting Rank Math support, and sorry for the unexpected delays and any inconvenience that might have been caused due to that.
1. Once you marked the robots meta as noindex
the URL will automatically be excluded from the sitemap page.
As for the rank_math/sitemap/entry
filter, the function will loop all entries of the URL before it will be added to the sitemap. Here’s and example of implementation of this filter:
add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ){
$post_id = $object->ID;
if( has_term( 111, 'category', $post_id ) ) { // Change 111 to the ID of the category
$url = false;
}
return $url;
}, 10, 3 );
2. Those sitemap pages are individually generated by Rank Math so you would need to uncheck “Include in Sitemap” one by one under the Taxonomies group in your Sitemap settings:

Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Hello Jeremy,
thanks for your answer.
Once you marked the robots meta as noindex the URL will automatically be excluded from the sitemap page.
When this is done through a filter, the url still appears in the sitemap.
I tried to use the filter you gave me. Maybe I did something wrong ?
function rank_mmath_exclude_from_sitemap ( $url, $type, $object ) {
$excluded_terms = array( 1196, 506 ) ;
foreach ( $excluded_terms as $term_id ) {
$url = false;
}
return $url ;
}
}
add_filter( 'rank_math/sitemap/entry', 'rank_mmath_exclude_from_sitemap', 0 , 3);
But terms 1196 and 506 are still listed in the sitemap of their specific taxonomy. And it also makes the sitemap much slower.
Hello,
Here is an example of how to use the filter for excluding terms from the sitemap:
add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ){
$terms = array( 19, 104 ) ;
foreach($terms as $term)
if ($object->term_id == $term && $type = 'term') {
return false;
}
return $url;
}, 10, 3 );
And if you have a lot of terms, the filter will slow down the sitemap loading as it has to go through all the terms and exclude the ones mentioned in the filter.
Hope this helps. Let us know if you need any other assistance.
Thanks.
Thank you Jaideep,
it works perfectlly, but slowly, indeed.
Is there a way to improve that by caching ?
Hello,
Try increasing your PHP values such as Max input time
or PHP time limit
. However, our filter will loop each item and we can’t do anything than that as that’s how the filter works.
You may also try decreasing your links per sitemap and see if this improves the speed. You may change it by heading over to your WordPress Dashboard > Rank Math > Sitemap Settings > General > Links per Sitemap.
Let us know how that goes. Looking forward to helping you.
Thanks Jeremy.
I’m on localhost currently, so in any case the performance is awful. My question was more “can the sitemap be stored in a transient or cached by a plugin?”
Hello,
Yes, the sitemap can be cached to further improve the speed, that is completely fine although that would not be ideal if you are frequently updating your content since you would need to flush the sitemap cache manually.
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Hello,
We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.
If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.
If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.