Show post creation and modified date

I’ll occasionally return to a post and revise it for improved methodology, test results or whatever. But the ‘posted on’ date always remains the same, even after the post has been updated. I feel that displaying only the ‘posted on’ date could be somewhat confusing, particularly when I state that I’ve updated the post in a comment dated months later. So, in the interest of full disclosure, I have added a few lines of code to the WordPress ’single.php’ template file to supplement each post’s meta data with the date it was last modified. If the post has never been modified or if it was last modified within 24 hours of the ‘posted on’ date, only the ‘posted on’ date is shown.

Original code found here but modified below: http://www.ardamis.com/2007/01/13/showing-a-wordpress-posts-last-modified-date/


<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">Read Article ›</a><br/>
 This entry was 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 + 86400) {
 echo "and last modified on ";
 the_modified_time('F jS, Y');
 echo ", "; }
 ?>

Revisions

There are no revisions for this post.

Tags: , ,

No comments yet.

Leave a Reply