You want to exclude a post or page? If yes then in Rank Math There is an option present no index mark the option. Then that specific post or page will be set as no index and exclude from the Site map.
Thank You!
Also, Wait for Support Member’s response.
I want to exclude from posts. I am aware of this feature. But my question is, how I can exclude from sitemap based on a string in url.
I can’t go through to check post by post to check multiple strings if they are in url or not.
Hello,
Thank you for getting in touch.
I am afraid we do not have such a feature in place.
Assuming all you need is for such posts to be excluded from indexing, you can achieve this by applying the noindex meta dynamically for all those URLs as follows:
/**
* Allows filtering of the robots meta data.
*
* @param array $robots The meta robots directives.
*/
add_filter( 'rank_math/frontend/robots', function( $robots ) {
global $post;
// filter for only a specific post type
if($post_condition == true){
$robots['index'] = "noindex";
$robots['follow'] = "nofollow";
return $robots;
}
return $robots;
});
Please note you will need a developer to customize this code further to apply this only to posts with your unique condition.
Hope this helps you. Thanks.
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.