Do you want to show the last updated date for your posts in WordPress instead of published date?
In this article, we will show you how to easily display the last updated date of your posts in WordPress.
Why You Need Last Updated Date for Posts in WordPress?
Most WordPress themes usually show the date when a post was last published. This is fine for most blogs and static websites.
However, WordPress is also used by websites where old articles are regularly updated. This last updated date and time is important information for those users and sometimes google.
The most common example is news websites. They often update old stories to show new developments, add corrections, or media files. If they only added the published date, then their users would miss those updates.
Many popular blogs and websites don’t show any date on their articles. This is a bad practice and you should never remove dates from your blog posts.
Having said that, let’s see how to easily display last updated date for your posts in WordPress.
Default Method
Works with most theme,
Add the following code in themes function.php file at the very bottom of rest of the code.
function wp_last_updated_date( $content ) {
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time('F jS, Y');
$updated_time = get_the_modified_time('h:i a');
$custom_content .= '<p class="last-updated">Last updated on
'. $updated_date . ' at '. $updated_time .'</p>';
}
$custom_content .= $content;
return $custom_content;
}
add_filter( 'the_content', 'wp_last_updated_date' );
This code checks to see if a post’s published date and last modified dates are different. If they are, then it displays last modified date instead of published date.
Method 2
Because Many WordPress themes now use their own template tags which define how these themes show post metadata like date and time.
Some themes also use content templates or template parts to display posts.
Few simpler themes will use single.php, archive.php, and other template files to show content and meta information.
You to find the code responsible for displaying the date and time. As each theme is different you would need to check with your theme’s support for where the published date is located.
Then You need to replace the code with the below code. Your default code should look very similar to the code below.
<div class="thetime updated"> <span><?php the_modified_date(); ?></span></div>
If you having an issue with 2nd method. Please let me know so I can help better according to your theme.
SEO BENEFITS
Through patent filings over the years, Google has explored many ways that it might use “freshness” as a ranking signal.
Former Google Fellow Amit Singhal once explained how “Different searches have different freshness needs.”
The implication is that Google measures all of your documents for freshness, then scores each page according to the type of search query.
Singhal describes the types of keyword searches most likely to require fresh content:
- Recent events or hot topics: “President Elections”
- Regularly recurring events: Such as Sports Events
- Frequent updates: “Siteground Reviews”
Google may determine exactly which queries require fresh content by monitoring the web and their own huge warehouse of data, including:
- Search volume: Are queries for a particular term spiking (i.e. “Earthquake Los Angeles”)?
- News and blog coverage: If a number of news organizations start writing about the same subject, it’s likely a hot topic.
- Social media: A spike in mentions of a particular topic may indicate the topic is “trending.”
While some queries need fresh content, other search queries may be better served by older content.
Fresh is often better, but not always.
In my opinion, the “freshness factor” is one of the reasons, why Wikipedia works so very well.
They have one URL per topic that never changes. But the content on that page is updated regularly.
For example:
A news magazine will probably add a new article about WW2 every time there is an anniversary or something to report.
Wikipedia on the other hand, has one page with all the information:
https://en.wikipedia.org/wiki/World_War_IIIn addition, it is updated very regularly.
https://en.wikipedia.org/w/index.php?title=World_W…Therefore, if somebody is searching for “World War 2” in general, it is much better from googles point of view to show them the one page with all the information, than any article that only looks at a facet of the topic.
Moreover, of course, all the ranking signals are combined in this one URL, too, and not diluted across many Pages.