Know how to display the last updated date of your posts in WordPress.597

Know how to display the last updated date of your posts in WordPress.
Author: InfoBeep - September 12, 2017 | subject to copyright

If you regularly update your site and want your user to know when the given article was last updated. Here is how you can do it.


When you need last updated date for posts in WordPress?

In today’s scenario, things are being updated regularly and most of the website owners as well as viewers wants to have the updated information.

There are also sites like News websites who update the news commonly. So that, the readers would know when was news published.


Displaying last updated Date in WordPress

There are 2 different methods to adding last updated Date in WordPress. In both the method you need to paste codes in WordPress.

Method1: show last updated date before post content

In order to show last update date in your WordPress, follow the instruction below:

  • Add the code below to your theme’s function.php file or a site-specific plugin.



function ib_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', 'ib_last_updated_date');

  • The above code checks the published date and last modified date. If found different, it displays last modified date to the post content.

(Note: In order to make your last modified date attractive you can add custom CSS. Demo code is given below):

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

Method 2: Add Last Updated Date in Theme Templates

In this method, you need to edit specific WordPress theme files.

Most of the themes use single.php, archive.php and other template files to show information. After, opening those files you have to search for codes that display the date and time.

Now, you can copy the code below and either replace it or add it right after your theme’s date and time code.


$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 86400) {
echo "<p>Last modified on ";
the_modified_time('F jS, Y');
echo " at ";
echo "</p> ";

This will generate the last updated post on your wordpress website.