(+84) 463.28.7979

Display the Last Updated Date of Your Posts in WordPress

WordPress is being used for many purposes. Some are for blogs, whereas others are news sites. When you pubilsh a news story, there are often times you might need to make updates. In this tutorial we will share how you can let your users know that the post was updated. We will highlight how to display the last updated date of your posts.

For example, if you posted an article on July 19, 2009, and you found out three days later that there was an update to the story. You can just edit the article, and it will show July 22, 2009 at the timestamp for last update.

First you need to open these three files:

  1. index.php
  2. single.php
  3. page.php

Then you will need to locate the following code:

Posted on: <?php the_time(%u2019l, F jS, Y%u2019) ?>

Note: Since there are so many formats of displaying dates, you might not see the exact code, but something along this line.

Replace it with:

Last Update on <?php the_time(%u2019F jS, Y%u2019) ?>
<?php $u_time = get_the_time(%u2019U’);
$u_modified_time = get_the_modified_time(%u2019U’);
if ($u_modified_time != $u_time) {
echo “and last modified on “;
the_modified_time(%u2019F jS, Y%u2019);
echo “. “; } ?>

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>