How to Add Last Modified Date in WordPress Default Sitemap

Last Modified Date

in Default WordPress Sitemap have not any type of Last Modified Date date in URL. So You Add Last Modified Date in Your WordPress custom theme without plugins. Simple paste given code in your theme’s functions.php file.

How To

  • login in cpanel
  • open active themes folder and then open functions.php
add_filter( 'wp_sitemaps_posts_entry', function( $entry, $post ) {
$entry['lastmod'] = date( DATE_W3C, strtotime( $post->post_modified_gmt ) );
return $entry;
}, 10, 2 );
  • Then SAVE functions.php file after paste given code.