WordPress Tip: Add modified dates to posts

wordpress-3-1On more than one occassion, I have read through an article that seamed relevant until I realized that the date of the article maybe years old. In many cases, the authors have made changes to the article, but the reader really isn’t sure about the content of the article because of the age, so they simply pass over the article, regardless of the likelyhood that the content is up-to-date and relevant.

I have modified a piece of code that I use, currently on my megocollector site, to alert the reader of the last time the article has been modified.The code will do two things. It firsts determines the article (or post) time of creation and then compares it to the last modification time. If the creation and modification times are identical, then the code will not display a modified date. However, if the times are not identical, then the modified date will display.

<?php $origdate = get_the_time(); $moddate = get_the_modified_time(); if ($origdate != $moddate): echo '<strong>Modified: </strong>'; {the_modified_date();}; endif; ?>

To use this code, I placed this code in the single.php file where I wanted to display.