Adding a modificaction date for a post

#935057
  • Pedro
    Rank Math free

    Hi,

    How can you show users not only the publication date of a post but also the date the post was last updated?

    I would like to manually select that date, so I can notify users, and Google’s bot, when substantial changes have been made to the post, rather than for minor updates.

    We should ensure that the RankMath plugin updates the LastModified parameter in the XML sitemap with the choosen date and it will be necessary too to verify the structured data, particularly datePublished and dateModified.

    Can you help me, please?

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting us and bringing your concern to our attention.

    Rank Math automatically includes the modified date when you use the Article schema on your posts/pages. However, you can also use and modify the following filter on your website to change the modified date on your pages:

    add_filter( 'rank_math/opengraph/facebook/article_modified_time', function( $date ) {
    	$date = '2024-12-20T07:27:42+00:00';
    	return $date;
    });
    
    add_filter( "rank_math/snippet/rich_snippet_article_entity", function( $entity ) {
      $entity['dateModified'] = '2024-12-20T07:27:42+00:00';
      return $entity;
    });
    

    For sitemap, you can modify the filter code mentioned here: https://rankmath.com/kb/filters-hooks-api-developer/#remove-lastmod-in-sitemap

    Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps and please don’t hesitate to let us know if you have any other questions.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this ticket.