How to: Display the last modified date of your posts

Do often edit your published posts to update or complete it? If yes, I guess you’d like to be able to display the last modified date. Good news for you, here’s a complete code to do that.

In your single.php and/or inde.php, look for the following line:

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

And replace it by:

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 ". ";
} ?>

Credit goes to Kyle Eslick for this awesome recipe!

Related Posts

No related posts.

2 Responses

Nov 17 2008 09:22

I think this is needed in earlier versions of WP.. the current release doesn’t change the date to the latest modified draft

Dec 05 2008 03:30

and i wanna add a recipe in this code. you can use it with current modified time with date :)

it will be like this
and last modified on February 23rd, 2008 at 03:16.

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required