How to Show Last Updated Date in WordPress Blog Posts

WordPress CMS platform is mostly used for blogging purpose. We bloggers usually update our old posts whenever we find anything new information about particular topic. Users always loves to read updated content. If you show outdated content on your blog then no one will return back to your blog. Usually users first check the date of the post to find whether the content is up to date or not.  If you update your blog posts regularly and show published date then users will thing that post is never updated. So, its a good idea to show the last modified date in your WordPress blog posts. Most of the WordPress themes doesnt display last modified date in posts. Users will see only published date on your posts.

To show last updated date, you have to do some minor changes in your theme files. Today Im going to share an easy guide to show last updated date in WordPress blog posts.

How to Show Last Updated date in WordPress Blog Posts:

You have to edit the php files of your theme to show last updated date in your posts. To do this go to your WordPress blog Dashboard>>Appearance>>Editor and open single.php (Single Posts) and index.php (Main Index)  files of your theme. Then locate the following lines of code in both files:

<?php the_date('F jS, Y');?> 

or

<?php the_modified_time('F jS, Y');?>

Note: Theme developers use different formats of dates and codes to show dates in posts so you might not found the exact code. Try to find similar code to above line of code.

After finding the above code, replace it with below php code.

<?php $u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time != $u_time) {
echo "Last Updated on  ";
the_modified_time('F jS, Y');
echo ". "; } ?>

If you want show both published date and last modified date then use below code.

Published 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 "Last Updated on  ";
the_modified_time('F jS, Y');
echo ". "; } ?>

Then click on update file to update your theme file. To show the last modified date on your blog pages repeat the above process on page.php file of your theme. If above code doesnt work on your theme then you can use WP Last Modified Plugin to do the same.