Hello,
Thank you for your query and we are so sorry about the trouble this must have caused.
We are assuming that you are using a 3rd party plugin to create News Sitemaps because you have a free account with us and the News Sitemap is available in PRO.
You can easily exclude any posts you want from Rank Math’s regular sitemap by going to WordPress Dashboard > Rank Math > Sitemap Settings > General and adding the IDs of the posts you want to exclude.
Here is a screenshot for reference:
Hope that helps and please do not hesitate to let us know if you need my assistance with anything else.
I am using pro rankmath provided by agency license of third-party.
I can’t exclude individual posts as its too much tough.
I want to exclude categories.
Same as it allows to exclude categories in news sitemap of rankmath pro.
Hello,
To exclude all the posts form a particular category from the sitemap you can add the following filter on your website:
add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ) {
if(get_the_category($object->ID)[0]->slug == 'category') { //Change the value inside single quotes for the slug of the category you want to exclude
return;
}
return $url;
}, 10, 3 );
Please make sure that you make the necessary changes to the filter explained in the comment.
Don’t hesitate to get in touch if you have any other 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.