Unable to remove dates from schema snippet and sitemap

#1035753
  • Resolved codade
    Rank Math free

    Hi tried removing dates from my webpages html and was able to remove all dates from the html code except for the dates generated through the plugin. I followed your knowledge page:https://rankmath.com/kb/remove-dates-from-search/ and at least accomplished to remove dates from the opengraph tags, but unfortunately the other two filters (the one for the schema date removal and the sitemap last-mod removal) seem not work.
    The sitemap now hides the last modification date on the landing page */sitemap_index.xml, but as soon as you open subpages (e.g. post-sitemap.xml) all modification dates are still there. I also untoggled the button to include dates in the sitemap from the wordpress dashboard.
    The filter for the date removal in the schema snippets seems to not work at all, since all dates are still present.
    Did the code change and therefore the hooks?
    Thanks for your help!

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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:

    1. 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;
      });
    2. 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!

    codade
    Rank Math free

    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.

    codade
    Rank Math free

    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.

    codade
    Rank Math free

    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.

Viewing 7 replies - 1 through 7 (of 7 total)

The ticket ‘Unable to remove dates from schema snippet and sitemap’ is closed to new replies.