One of the most common meta-data in a blog post is the date. Its the day, on which you first published a blog post. Having date displayed on your blog post is more important for the reader.
It helps to find out the freshness of the information, understand the relevancy to today’s situation and of course, to know when it was published.
For a news blog, date field is mandatory to use in order to know exactly, on what day a particular event had happened.
However, for a blog like mine where most of the information are timeless and valid for so many years, displaying the published date is not so relevant. Because timeless content can be read any time in a year and also, they can be constantly updated to make it more useful to the readers. In that case, instead of displaying the published date, we can display the last modified date.
This helps the reader, to understand the information in this page is up-to-date.
- Apart from the reader, search engine like Google is giving more weight-age to the date displayed on a page.
- In fact, Google always shows the fresh and latest pages on the top.
- There are also options available to filter by last week, last month etc. on Google.
Basically, when you keep your page updated it is not enough. You have to tell Google that you have updated this page on this latest date. Doing so adds lot of advantage to your blog, Google keeps your page under the latest list and shows it often on the SERP (result page).
Naturally, this drives more traffic to your blog because you have up-to-date information.
Almost all WordPress themes in the market are showing only the published date. Hence you have to edit your themes source code, in order to show the last modified date.
- The API to display last modified date is: the_modified_date().
- This API takes multiple arguments. However, I suggest you to ignore and just use this API only to display the date.
Here is an example:
Last updated on <?php the_modified_date(); ?>
gives an output like:
Last updated on June 16th, 2015
The format of date can be changed from your WordPress dashboard.
Go to Settings > General and you can change the default date format.
Generally, with most of the themes, you have to locate and replace the existing API get_the_date(…) or the_date(…) with the new API the_modified_date().
The date fields are displayed:
- on posts located from Single Post (single.php)
- on pages located from Page Template (page.php)
- on homepage located from Main Index Template (index.php)
- on archives located from Archives (archive.php)
Hope this post helps to show the last modified date in your blog post.
Leave a comment, if you find any difficulties in changing this code.
I will try to help you.