Hello, we apologize for the inconvenience you’re facing. It seems that you’re trying to remove the last modification date from your XML sitemap using our guide, but it wasn’t deleted everywhere as expected.
To remove the last modification date from your XML sitemap, you can use the following filter if you have Rank Math installed:
/**
* Filter to remove lastmod from sitemap index
*/
add_filter( 'rank_math/sitemap/index/entry', function( $index, $type ) {
if ( isset( $index['lastmod'] ) ) {
unset( $index['lastmod'] );
}
return $index;
}, 10, 2 );
If you’ve already used this filter and it didn’t work as expected, please provide us with more details about where the last modification date is still appearing so that we can assist you further. If you have any other questions or need further assistance, please feel free to let us know.
Sources:
Indexed, Not Submitted in Sitemap – Google Search Console » Rank Math
How to Remove Date Snippets from Search Results » Rank Math
How to Configure Sitemaps in Rank Math – Best Settings and Tips
Hello,
Apologies for the inconvenience.
Please note that the filter above only affects the sitemap index.
However, if you wanted to remove the last mod from all of your sub-sitemaps, then you may need to add this filter as well:
add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ){
if ( isset( $url['mod'] ) ) {
unset( $url['mod'] );
}
return $url;
}, 10, 3 );
Once done, please clear your website’s cache and flush the sitemap cache as well:
https://i.rankmath.com/pipRDp
Moreover, we recommend that you shouldn’t remove the lastmod values from the sitemaps because that is what makes the sitemaps compliant with Google and other search engines.
If you remove that, it’s possible that the sitemaps can no longer be parsed correctly and the website not crawled consistently.
Hope that helps.
thanks for the help, but there is a small problem: the last mod was not removed everywhere
https://img.netpeak.net/masik/17CXX9K.jpg
https://img.netpeak.net/masik/17CXYRE.jpg
Hello,
Can you please try to follow the steps below and see if that works for you?
1. Flush the Sitemap cache by following this video screencast:
https://i.rankmath.com/pipRDp
2. Exclude the Sitemap files of the Rank Math plugin in your caching plugin. The cache could be via a plugin or from the server. For plugins or Cloudflare, please follow this article:
https://rankmath.com/kb/exclude-sitemaps-from-caching/
3. If the above steps don’t seem to work, kindly apply the following filter to your site.
add_filter( 'rank_math/sitemap/enable_caching', '__return_false');
Here’s how you can add filter/hook to your WordPress site:
https://rankmath.com/kb/wordpress-hooks-actions-filters/
Let us know how it goes. Looking forward to helping you.
Thank you.
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.