Hello,
We apologize for the issue you are facing with removing dates from the schema snippet and sitemap. Thank you for providing detailed information about the steps you’ve taken so far.
To ensure that the filters for removing dates from the schema snippets and the sitemap are working correctly, please double-check the following:
-
Sitemap Last-Modified Date: Make sure you are applying the filter correctly to all types of sitemaps. The filter you mentioned should be applied to each sitemap entry. Here’s a reminder of the filter code:
add_filter( 'rank_math/sitemap/index/entry', function( $index, $type ) {
if ( isset( $index['lastmod'] ) ) {
unset( $index['lastmod'] );
}
return $index;
}, 10, 2 );
If this is not working for subpages, you may need to apply a similar filter specifically for post sitemaps:
add_filter( 'rank_math/sitemap/post/entry', function( $entry ) {
unset( $entry['lastmod'] );
return $entry;
});
-
Schema Snippet Date Removal: For removing dates from schema snippets, ensure that you are using the correct filter as well:
add_filter( "rank_math/snippet/rich_snippet_article_entity", function( $entity ) {
unset( $entity['dateModified'] );
unset( $entity['datePublished'] );
return $entity;
});
If this is not working, please verify that there are no conflicting plugins or theme settings that might be overriding these filters.
If you have checked all of this and it still does not work, we recommend replying to your ticket with your site URL so that a human agent from our support team can assist you further. They will be able to investigate the issue more thoroughly.
Thank you for your patience, and we look forward to resolving this for you!
HI, unfortunately adding the filters for every subpage of sitemap didn’t work. The code for the snippets is the one I tried, which is not working
Hello,
Thank you for your query and we are so sorry about the trouble this must have caused.
Please use the following filter code to remove dates from the WebPage
schema:
add_filter( 'rank_math/json_ld', function( $data ) {
unset( $data['WebPage']['datePublished'] );
unset( $data['WebPage']['dateModified'] );
return $data;
});
As for the lastmod
in your sub-sitemaps, you shouldn’t remove the lastmod
values from the other 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.
This is why the available filter for the lastmod
removal is for the index sitemap only.
Hope that helps.
Thanks for your quick help.
That worked for me!
Hello,
We are glad that everything has been sorted out.
Do you still need our assistance with anything else or can we go ahead to close the ticket?
We look forward to hearing from you.
Thank you.
Thank you. No further assistance needed!
Hello,
We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.
If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.
If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.