How To Show Post Last Updated/Modified date without any Plugin?

With the help of this post, you can increase the rank of your website in Google Search. This is the best way to SEO of your posts.
This post is about showing the last updated date or last modified date on your post. With the help of this post, this strategy will work on any theme of your website. As such will work on any theme including GeneratePress Premium.

How To Show Post Last Updated/Modified date without any Plugin?

This trick is only for WordPress users. You can check this video, the video given below. You can do it very easily, just follow this simple process. To show post last updated/modified date without any plugin apply below PHP code and It’s Working 100%.

Best Hosting With FREE Domain

Hosting with FREE Domain (Hostinger) (65% OFF): https://bit.ly/3sz1p4l
👉Bluehost Hosting (Extra Discount): https://bluehost.sjv.io/Zd5Aj0
👉CloudWay Hosting 30% Discount Linkhttps://bit.ly/3eU0bgP
Apply 40% Coupon Code: “BFCM4030

Show Post-Last Updated/Modified date without any Plugin Video

Post-Last Updated/Modified date PHP Code

To show when a post was last updated, you can use the last_modified_gmt field in the WordPress post object. This field contains the post’s last modified date and time in the GMT time zone. You can use the date_i18n function to format the date and time in a human-readable format and display it on your website.

See also  How to Increase Website Speed in WordPress: Full Guide

Here is an example of how you can display the last updated date and time of a post in WordPress:

This will display the last updated date and time in the format of “Month day, Year” e.g “January 17,2023”
You can use the get_the_modified_date() or get_the_modified_time() for the same.
Copy the below code and paste it into your WordPress Website Theme function.php file.

// Post Last Updated/Modified date By Techno Tricks Suman
add_filter( 'generate_post_date_output', function( $output, $time_string ) {
$time_string = '';
if ( get_the_date() !== get_the_modified_date() ) {
$time_string = '';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
return sprintf( '%s ',
$time_string
);
}, 10, 2 );