Usually, most of the WordPress themes display article’s published date in the blog posts and my theme was also one of them but not now. In fact, now I’m displaying the last updated date in the single posts by replacing publishing date. So, with the help of this article, I will tell you how I’m displaying the last updated date in my WordPress blog posts.
Yes, I use WordPress for maintaining my technology blog. First of all, I want to tell you the reason that why I’ve replaced article publishing date with the last updated date. Here’s a few reasons for that:
User Experience: I’ve made this change just because of the readers to make them know that when was this post last updated.
Search Engine Optimization: A few days ago, I’ve published an article on powerful factors to know how Google ranks your website. In that article, I’ve clarified that Google always love the fresh content so you should always keep updating your content. And if you replace your article’s publishing date with last updated date, this modified date will also show up in search results by replacing the publishing date, which is the best thing to rank your site higher in search results.
These two reasons were enough for me to replace the publishing date of my articles with the last updated date to show the last updated date when I update my post to make it fresh again.
Here’s How I’m Displaying the Last Updated Date in WordPress
When I was thinking to replace the publishing date of article with last updated date, I read many blogs to know about it. All of them are full more than 5 lines of code and I think which is useless. In fact, for such a simple task why should I use such lines of code.
I was right when I found a simple Function Reference in WordPress Codex i.e, the_modified_date() and successfully displayed the last updated date in the posts.
So, the one line of code to display the last updated date in your WordPress blog posts is following:
<p>Last Updated: <?php the_modified_date(); ?></p>
Now, I tell you that where and how you can add this code to your WordPress theme. So, quick open single.php file from theme editor and look for the term something like <p>Published on: <?php the_time(‘F j, Y’); ?></p>. You can replace this code with the above provided code to show the last updated date in your single posts.
In simple words, all you need to do is just replace the_time (‘F j, Y’) with the_modified_date() and that’s it.
However, it will just change the date in single posts or article pages not in the home page, category pages or archive pages. So, to display the past updated date in home page or archive pages too, just make the similar change in index.php and archive.php files of your WordPress theme.
More WordPress Tips:
The Easiest Alternative for Beginners to Show Last Updated Date
However, the above method is very easy, prominent, and technological, nevertheless if you’re a beginner, you may find it quite difficult. I’ve an alternate way to display the last updated date in your WordPress blog posts without replacing the publishing date.
A WordPress Plugin named WP Last Modified can be used to display the last updated date in your WordPress blog posts. You just need to install this plugin and after activating it will start displaying the last modified date in your blog posts without having to do anything more.