How to Display last Updated Date Of Your Posts in WordPress

If you are updating your old posts regularly and want to Display the last updated date Of Your Posts in WordPress to your readers so that they know the content is still relevant. This will always help the readers to ascertain the freshness of the post.

In this article, we will show you how you can easily display the last modified or updated date of your posts in WordPress.

You will learn how to do it

1: Without a Plugin using a code snippet.
2: With a Plugin.

While each method is fairly similar, there are some differences between them which I will point out.

Why do you need to display the last updated date for posts?

The problem is, WordPress by default only shows the date when the post was published, WordPress does not display the date when you update it.

This may be fine for some blogs and static websites. But many blogs hosted on WordPress gets regularly updated old content.

If you are a blogger and you may have posts published some years back and the contents of which are still relevant today. You may update those old posts, maybe like correcting some spelling mistakes, adding a link to your new posts, in such instances its good to display the last updated date.

Having said that, letโ€™s see how to easily display the last updated date of your posts in WordPress.

Method 1: Displaying the last updated date with code.

This method requires you to add code to your WordPress files. You will need to add this code to your themeโ€™s functions.php file.

This is the best and most permanent way to show the latest updated date on your articles.

How to add this code?

On your WordPress dashboard, go to Appearance > theme editor. Make sure to choose the theme you are using.

Note: Though its a very safe method, before you proceed further please take a backup of your functions.php file.

On the theme editor page select and click to open the “functions.php” file of your theme. Copy and paste the code snippet at the bottom of the functions.php file. Then save your file.

function tnf_last_updated_date( $content ) {
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time('F jS, Y');
$updated_time = get_the_modified_time('h:i a');
$custom_content .= '<p class="last-updated">Last updated on '. $updated_date . ' at '. $updated_time .'</p>';
}
$custom_content .= $content;
return $custom_content;
}
add_filter( 'the_content', 'tnf_last_updated_date' );

This code works by checking the post-publication date and comparing it against its โ€œlast modifiedโ€ date to determine if the two dates are different. If they are different, the post will display the โ€œlast updatedโ€ date with the text โ€œLast updated on.โ€ See the image below as an example

That’s it, this will show the last updated date and time just below the post title.

If you want to customize the style of the โ€œlast updatedโ€ text, You can add custom CSS to style the appearance of the last updated date. Here is a little CSS that you can use as a starting point and modify it as per your needs. For example changing the font size, background color.

.last-updated {
font-size: small;
text-transform: uppercase;
background-color: #fffdd4;
}

Add the above CSS code in your themes additional CSS option. This you will find under Appearance > customization > Additional CSS.

It is recommended that you make these changes in your themes child theme. So if your theme gets updated the code will remain in your child themes function.php file.

If you don’t know how to create a child theme, you can read our detailed post on how to create a child theme for any WordPress theme.

Check out: How To Duplicate Files From The Parent Theme To Child Theme

Method 2: How To Show Last Modified Date With A Plugin

If you are not comfortable with editing theme files, using a plugin is the easiest way to show the โ€œlast updatedโ€ date on your WordPress posts because you donโ€™t have to look for or replace any code.

WP last modified info plugin is what you should use to display the last modified date on your posts. It’s a free plugin and has a 5-star rating.

What does this plugin do?

This plugin automatically inserts last modified or updated info on your WordPress posts (including custom post types) and pages. See the image below.

It is possible to use shortcode [lmt-post-modified-info] for posts and [lmt-page-modified-info] for pages for manual insert.

This plugin also adds โ€˜dateModifiedโ€™ schema markup in WordPress posts automatically and it is used to tell the last modified date & time of a post or a page to various search engines like Google, Bing, etc. Improves SEO.

Provides you with options to display the last modified/last updated date above or below your posts and pages.

You can also set date/time formats and the position of the timestamp in WordPress Posts and Pages which can be either before content or after the content.

Allows you to customize the text which is to be displayed alongside the last modified date (default is: Last updated on).

Which Method Should You Use On Your Site?

For most bloggers, I think the first method is the best because it is flexible and also fairly easy to implement.

If you are not comfortable with editing theme files and want something simpler, go for the plugin method.

I hope this article helped you learn how to Display last updated date Of Your Posts in WordPress

If you liked this article, then please subscribe to our YouTube Channel. You can also find me on Twitter and Facebook.