Add a lastmod date to every post and page in WordPress's sitemap, so search engines know what changed.
add_filter( 'wp_sitemaps_posts_entry', function ( array $entry, WP_Post $post ): array {
$entry['lastmod'] = get_post_modified_time( 'c', true, $post );
return $entry;
}, 10, 2 );
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
WordPress’s built-in sitemap lists URLs but not when they last changed. Search engines use lastmod to decide what to recrawl first, so adding it helps updated content get picked up sooner.
Each URL in a post type sitemap passes through wp_sitemaps_posts_entry. The snippet adds the post’s modified time in UTC, in the ISO 8601 format sitemaps require. WordPress’s sitemap stylesheet then shows a “Last Modified” column.
Open yoursite.com/wp-sitemap-posts-post-1.xml. Each URL should now show a Last Modified date.