Free Wordpress Blog Setup

Display the Last Updated Date of Your Posts in WordPress

By Editorial Staff in Tutorials
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 ". "; } ?>

What Next?

Digg it
Save This Page
Subscribe to WPBeginner
Stumble it
Free Wordpress Blog Setup

Comments

One Response to “Display the Last Updated Date of Your Posts in WordPress”
  1. jan geronimo says:

    Wow, you have many useful posts here on WordPress. You’ve forced my hand. I’m subscribing now to your feed. What a useful site you have here. I’m very impressed.

Share Your Opinions

Tell us what you're thinking...
and if you want a pic to show with your comment, then get gravatar!

Please make sure that you have read our Comment Policy.

Due to high volume of request from our readers, we are adding this feature that allows you to stay updated with this post's comments without having to participate in the discussion even though we would love your input as always. Don't worry we hate SPAM just as much as you do, so you will never receive any SPAM messages from our site and that's our promise to you.

Subscribe without commenting

Close Bar