Are you searching for a way to show when posts were last updated in WordPress? By default, WordPress will display when a post was published, but some websites may have a need to update a post.
For those who do, you will find that WordPress does not have a built-in feature to display the updated date. However, like most things in WordPress, there is a plugin to do so.
Today, I will demonstrate how to show when posts were last updated in WordPress by using the WP Last Modified Info plugin and with PHP code.
Why Display the Update Date
Perhaps the most important aspect of updating content is the schema markup for search engine optimization. Adding the update information helps sites like Google record when the content was last modified.
But, there are many other reasons why someone may want to display the last time a post was updated.
For example, let’s say you run a news blog. In most cases, you would report the initial information for a story. Then as more information becomes available, you would edit the post to reflect the new details.
Another great example is a weather report. Let’s say there is a hurricane moving towards an area. You would periodically update the post to reflect any updated forecast information.
This isn’t just useful for news and weather websites either. Tutorials, service outages and many other types of posts are regularly updated. It helps visitors know that what they are reading is relevant.
Installing WP Last Modified Info
The WP Last Modified Info plugin is a very easy tool to use. After installation, it’s as simple as changing one option in the plugin’s settings.
Let’s start by clicking on Plugins and selecting the Add New option on the left-hand admin panel.
Search for WP Last Modified Info in the available search box. This will pull up additional plugins that you may find helpful.
Scroll down until you find the WP Last Modified Info plugin. Click on the “Install Now” button and activate the plugin for use.
Using WP Last Modified Info
On the left-hand admin panel click on Settings and select the WP Last Modified Info option. This will pull up the plugin’s settings page.
By default, the plugin is off. To turn it on, simply click on the “Enable for Posts on Frontend” button. It will be red when it is off and green when it is on.
The following settings allow you to customize the appearance of the message displayed. For most websites, the default options will work well. However, if you want to personalize the message, you can.
Once you are done changing the settings, click on the “Save Settings” button.
All of your posts will now display when they were last updated.
Congratulations, you have successfully displayed the last time a post was updated on your website.
PHP Method
While plugins are the easiest way to add this feature, some may not want to add another plugin to the website. The more plugins you add, the slower your website gets, which can impact your SEO efforts.
Adding PHP code is really simple and in most cases. You don’t even need to understand the code to get the benefit. In reality, you can easily copy and paste PHP code snippets into your website, but before going any further, I strongly recommend making a backup.
This will ensure that if a mistake is made that makes your website unresponsive, you can revert back before changes were made.
Locate your theme’s functions.php file and paste the following code into it:
function display_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 .= 'Last updated on '. $updated_date . ' at '. $updated_time .'
'; } $custom_content .= $content; return $custom_content; } add_filter( 'the_content', 'display_last_updated_date' );
This code will display the message like so:
As you may notice, this also adds the exact time the post was updated, which is quite handy for time-specific news.
Keep Your Content Up To Date
As websites age, older content may lose their relevance or have inaccurate information. The solutions to these problems are to delete the content or go back and make updates.
Most SEO experts agree that leaving old content that is out of date on your website is bad, which is why I recommend keeping your content up to date. Sometimes, this is also not possible and in those cases, deletion or redirection is the better choice.
Do you prefer using plugins or code to solve problems in WordPress? How does your website handle updating older content?
thank you so much this has help my site.
You are very welcome.