Hello,
I apologize for the issue you are facing with the custom post type (CPT) rewrite in your sitemap. It seems that the URL with the taxonomy term is being included in the sitemap, and you’re having trouble removing it using the provided filter.
To address this, you can try modifying your filter function to specifically check for the URLs you want to exclude. Here’s an example of how you might adjust your code:
add_filter('rank_math/sitemap/entry', function($url, $type, $object) {
// Check if the URL contains the specific slug you want to exclude
if (strpos($url['loc'], '/formations/') !== false) {
return null; // Return null to remove this entry from the sitemap
}
return $url; // Return the URL if it doesn't match
}, 10, 3);
This code checks if the URL contains /formations/
and removes it from the sitemap by returning null
. Make sure to place this code in your theme’s functions.php
or in the rank-math.php
file as appropriate.
If this does not resolve your issue, please reply to this ticket with your site URL so that we can assist you further. Thank you for raising this concern!
Sources:
Rank Math Sitemap Issues and Their Fixes » Rank Math
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.