How To Display Last Modified Date On WordPress Post

Posted by

Hi,

In many cases you may want to display updated date of your post meta data rather than showing just the original published posting date. For that you need to edit the single.php file of your theme. Before edit the single.php take a backup of this file.

Now, find the Code:

Posted on: <?php the_time(‘l, F jS, Y’) ?>

Replace with:

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 will shows the last modified date immediately after the original published date rather than just showing the original post date.

That’s it!

Thanks,

Shane G.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.