Hello,
Thank you for contacting Rank Math and bringing your concern to our attention.
To exclude your posts/pages in your sitemap, please head over to WordPress Dashboard > Rank Math > Sitemap Settings > General.

And, here’s how you find the post/page ID inside WordPress: https://mythemeshop.com/blog/how-to-find-post-category-tag-comments-or-user-id-in-wordpress/
Please note that some options are only available when you enable the Advanced Mode in Rank Math. If it’s not showing, you must have chosen to use the Easy Mode. Please follow the steps in this link to switch to Advanced Mode:
https://rankmath.com/kb/advanced-mode/
I hope that helps. Thank you, and looking forward to your update.
Hi,
Thanks for your answer! I noticed this one, but we’ve got over 100 products that we’d like to exclude, and it’d be quite tedious to update that field every time we add a new product. But since they all have got specific type, I wondered if there’s any specific filter to use which would make things easier?
Something like
add_filter('exclude_post_id', function($excluded_ids){
return $excluded_ids;
});
Hello,
Thank you for the follow-up.
You can use and modify this filter to exclude your products from your sitemap:
/**
* Filter decision if post type is excluded from the XML sitemap.
*
* @param bool $exclude Default false.
* @param string $type Post type name.
*/
add_filter( 'rank_math/sitemap/exclude_post_type', function( $exclude, $type ){
return $exclude;
}, 10, 2 );
I hope that helps. Thank you, and looking forward to your update.
Hi Reinelle,
Thank you. This filter allows to exclude only by post type, so you may exclude e.g. “post” or “product”. Product type itself is a custom taxonomy, so if there’d be any filter for posts in given taxonomy (custom), then it’d be great. Or any filter that would give access to the post object or its ID, so I can check it myself.
Thanks,
Arek
Hello,
Thank you for getting back to us,
If the custom taxonomy is visible on the Rank Math title & meta settings you can set it to no-index to not be included in the sitemap. However, you could also go to the Rank Math sitemap settings and choose the custom taxonomies and then disable the option to include them on the sitemap.
We can point you in the right direction this time. Based on the data you shared in your previous reply, the code should look something like this:
add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ){
if ( $type == 'post' && get_post_type( $object ) == 'your-post-type' && has_term( Your-ID, 'property_action_category', $object ) ) {
return '';
}
return $url;
}, 10, 3 );
Please note that I have not tested the code and you may need to consult with a developer to get it working exactly the way you want it.
Also, you should know that sitemaps are cached and you may need to manually delete the cache to see changes after using filter codes. The cache files are located in /wp-content/uploads/rank-math.
I hope this helps. Please let us know if you have further questions.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.