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.

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. Follow Kyle on Twitter @KyleEslick!

  1. trying to figure out how to do this in K2 RC6 – thx for the pointers – RH

  2. trying to figure out how to do this in K2 RC6 – thx for the pointers

    <<< This ended up being pretty easy to do in WP 2.6 after a few trial / errors – just paste  the example you want to use from http://codex.wordpress.org/Template_Tags/the_modified_date into theloop.php ~ viola!

    … somewhere in the entry-meta div but not in the other php in there. For me line 141 was a good place.

  3. Kyle Eslick says:

    @ R. Richard – Thanks for sharing the fix you found.  Glad you got it figured out!  😀

    The K2 theme works a little different that most WordPress themes because of how they call the WordPress loop.  This makes hacks a little more difficult than they are for other themes.

  4. My way is the “quick, easy way” – someone with a little more time and patience and at least a measure of knowledge of php could certainly figure out how to to integrate the neccessary code in your hack into the K2 Loop.  It seems like it needs to all go in the entry_meta div.

    If we could only figure out a way to do all this stuff without messing with the core files… WP upgrades and themes are almost always a traumatic, time consuming experience.

    Anyway credit goes to you for pointing the way. Thx

  5. Parashuram says:

    I have used the undermentioned codes to get featured modified posts on my website.

    // show all featured coupons and setup pagination
    $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    query_posts( array(
    ‘post_type’ => APP_POST_TYPE,
    ‘ignore_sticky_posts’ => 1,
    ‘meta_key’ => ‘clpr_featured’,
    ‘meta_value’ => ‘1’,
    ‘orderby’ => ‘modified’,
    ‘order’ => ‘desc’,
    ‘paged’ => $paged
    ) );

  6. Bandar says:

    Is there a plugin in wordpress that show this without involving in editing the code?

  7. Bandar says:

    Is there a plugin in wordpress that show this without involving in editing the code?

  8. this might help. I’m using highlighted code directly to show last modified date. works for me.

Trackbacks/Pingbacks »

  1. 100+ Killer Wordpress Resources | Steffan Antonas' Blog says:
  2. Stupid WordPress Tricks | Serita says:
  3. WordPress Tricks Part 1 | [ XenriTech ].com says:
  4. 12 Lesser Known But Useful WordPress Hacks | php tutorial says:
  5. 12 Lesser Known But Useful WordPress Hacks | CSS Citadel says:
  6. Amy N Boon » 12 Lesser Known But Useful WordPress Hacks says:
  7. WordPress Tricks,,cuongvu marketing tips | cuongvu marketing tips says: