300x250 How To: Showing A Last Modified Date on Your WordPress Posts

On one of my main blogs I maintain several reference posts which are updated regularly in the hopes that they remain a valid resource for my readers. So far these posts have proven to be pretty beneficial to search engine traffic and well received by readers that reference them regularly.

If you run a blog where posts are regularly updated, you may want to consider updating your post meta data to also reflect the last modified date when applicable, rather than showing just the original posting date.

In order to do this, Ardamis has posted a quick code hack to get your single pages to reflect the last modified date. He uses the default Kubrick theme, but it easily apply to just about any theme.

As always, you’ll want to make a backup of your single.php file (or any files you will be changing) before proceeding.

Look for the code that displays the post date. It should look something like the following:

Posted on: <?php the_time('l, F jS, Y') ?>

Now replace it with the following code (slightly modified from Ardamis’ post):

Posted on <?php the_time('F jS, Y') ?>
<?php $u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time != $u_time) {
echo "and last modified on ";
the_modified_time('F jS, Y');
echo ". "; } ?>

Now your posts should show the last modified date immediately after the original posting date, rather than just showing the original post date! I use this on most of my blogs and I am very pleased with it.

Want automatic updates? Subscribe to our RSS feed or
Get Email Updates sent directly to your inbox!
  • Print This
  • Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level in 2007 by launching WPHacks.com as a place to share hacks, tutorials, etc. Connect with Kyle on Twitter or Google+!

    There Are 6 Responses So Far »