Hello,
Thanks for contacting us and sorry for any inconvenience that might have been caused due to that.
Please paste the code given below in the functions.php file of your theme/child theme.
/**
* Filter decision if 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 );
Replace the Post Type Name
with the name of your post type.
Hope this helps. Let us know if you need any further assistance.
I changed it as you suggested and unfortunately, it’s still showing, here’s a screenshot from locally(I tested it on other environments too)
https://ibb.co/ZWDfZ6B
/**
* Filter decision if post type is excluded from the XML sitemap.
*
* @param bool $exclude Default false.
* @param string $type article
*/
add_filter( ‘rank_math/sitemap/exclude_post_type’, function( $exclude, $type ){
return $exclude;
}, 10, 2 );
Maybe I’m doing a mistake on the code?
Hello,
Sorry for the delay and any inconvenience that might have been caused due to that.
If that code didn’t work then please use this code to directly exclude the URL from your sitemap:
add_filter( 'rank_math/sitemap/xml_post_url', function( $url, $post){
if('your url' !== $url) {
return $url;
}
}, 10, 2 );
Please flush the Sitemap cache by following this video screencast after pasting the code:
https://i.rankmath.com/pipRDp
Hope this helps. Let us know if you need any further assistance.
Ah this indeed seemed like a really good solution but unfortunately, it still didn’t, also would It be different if I had Pro instead because I use the Pro version on the live site I only use the free one in the developing environments, I wanted to use the exclude post section but since the post doesn’t exist I’m not sure how to get the ID thus why I wanted to remove the link like this
Hello,
I checked the code on my local site and it works fine. Please try by changing the permalink structure from WP Dashboard > Settings > Permalinks and save the settings then change it back to how it was and again save the settings.
Also, clear your site’s cache if you’re using any caching plugin.
Try this and let us know if this works for you or not.
We really look forward to helping you.
Indeed it seems the code is working when I tried it on another URL it removed it but for some reason it still won’t remove the /article/ URL might it be because there’s no post like that created?
Hello,
Thank you for the update.
Since the /article
is already non-existing, it should’ve been removed from your sitemap list after flushing your sitemap cache and excluding your sitemap from being cached.
Could you please try to use a 3rd party sitemap plugin to confirm if the issue still persists? Just make sure you have disabled the Sitemap module of Rank Math in WordPress Dashboard > Rank Math > Dashboard
when using a 3rd party sitemap plugin.
If the other plugin works, please do let us know.
Thank you, and looking forward to your update.
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.