Having Fun With Post Dates

Are there posts on your blog you regularly update rather than writing new separate entries such as tutorials for instance? Wouldn't it be nice if there was a way you could let your readers know when a post was updated other than adding an addendum to the bottom? Well there is.

WordPress outputs the date of a post by this tag,

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

You will find it any all of the template files that display posts such as index.php, single.php etc. Simply replace that bit of code with this,

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

The result will look like this,

postmod

About the author
Len has been blogging for over 10 years and is a rabid WordPress fan. In addition to blogging here you can find him writing the occasional article and toiling away in the forums at WeblogToolsCollection.com. He also hangs out at the WordPress support forums lending a hand where he can. You can also find him at his other blog LenKutchma.com

Leave a Reply

CommentLuv Enabled