Last Modified Dates in the XML Sitemap
Adds the date each post was last updated to the built-in sitemap, which helps search engines find changed content faster.
Opens WPIDE on
Code
add_filter( 'wp_sitemaps_posts_entry', function ( $entry, $post ) {
$entry['lastmod'] = get_post_modified_time( 'c', true, $post );
return $entry;
}, 10, 2 );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.