-
Hi there,
we need to exclude from the sitemap the posts automatically generated by the translation plugin.
Fortunately such posts are always after /en/blog/ path.
We tried to follow the documentation at this linkImplementing it like this way:
<?php
/**
* Filter the URL Rank Math SEO uses in the XML sitemap.
*
* Note that only absolute local URLs are allowed as the check after this removes external URLs.
*
* @param string $url URL to use in the XML sitemap
* @param object $post Post object for the URL.
*/
add_filter( 'rank_math/sitemap/xml_post_url', function( $url, $post){
if (!str_starts_with($url, 'https://7hype.com/en/blog/')){
return $url;
}
}, 10, 2 );
Unfortunately, it doesn’t work.
Where are we going wrong?Thanks for your help
Matteo
The ticket ‘exclude path from sitemap’ is closed to new replies.