Hello,
Thank you for contacting Rank Math today.
Well, not sure if you are aware that we have a method to exclude specific terms from your sitemap by using the following option in Rank Math > Sitemap > General:
As an alternative, you can try and customize the following function to target your terms.
/**
* Filter decision if a 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 );
Looking forward to helping you. Thank you.
Hi,
I am trying to exclude specific terms from custom taxonomies. The filters ‘rank_math/sitemap/exclude_post_type’ and ‘rank_math/sitemap/posts_to_exclude’ seems to work only for custom post types and not custom taxonomies.
Do you know of any other filters that may work with the terms from a custom taxonomy. Similar to Rank Math > Sitemap > General: Exclude Terms settings but as a filter?
Thanks
Hello,
You can modify this filter to exclude taxonomies.
/**
* Filter decision if taxonomy is excluded from the XML sitemap.
*
* @param bool $exclude Default false.
* @param string $type Taxonomy name.
*/
add_filter( 'rank_math/sitemap/exclude_taxonomy', function( $exclude, $type ){
return $exclude;
}, 10, 2 );
I hope this helps. Looking forward to helping you.
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.