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
👉Verpex Hosting (Extra Discount): Click Here
👉CloudWay Hosting 30% Discount Linkhttps://bit.ly/3eU0bgP
Apply 40% Coupon Code: “BFCM4030

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

https://www.youtube-nocookie.com/embed/tZXagX1ATJ4

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.

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 S Blogger
add_filter( 'generate_post_date_output', function( $output, $time_string ) {
$time_string = 'Published on: %2$s';
if ( get_the_date() !== get_the_modified_date() ) {
$time_string = 'Last Updated on: %4$s';
}
$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 );

Leave a Comment

Shopping Cart
Shop More Than $100 to get Free Shipping Shop Now
0

Shopping Cart
0

Scroll to Top

Join for New offers Coupon Codes