As I had to replace a snipet that did the same thing for a problem pHP 8 compatibility, I take this opportunity to leave here the steps to follow to show the date, and if you want the time, of the last update in your articles.
It can be added for almost all templates with CSS, a plugin (always the first option to discard) or a simple function, although with the Post Info widget from Elementor PRO widget (not available in the free version) simplifies the process and allows you to tweak the design a bit faster.
As well as informing your readers that it’s updated content you’ll be alerting search engines to the date that post was updated, it can regain rankings and show the update date in search results, which is beneficial for SEO.
Search engines tend to give love to pages that are updated regularly because it understands that content that is kept fresher is more relevant to readers.
Steps to display update date
1 – Drag the Post Info widget to the place in your template where you want to display the date.
2 – You choose the date format type and add the“Time” field as the second field. (You can also add the time later by pulling the format string of your choice without including that last “Time” field).
|l j F Y||Friday 9 July 2021|
|g:i a||13:30 am|
|g:i:s a||13:30:48 am|
Here are some all date and time formats time that you can use as you like.
3 – In“Before” you can add the text that will appear before the date.
4 – Another new date field is added under the date.
5 – In the“Type” option, select“Custom” and it will be renamed“Custom“.
6 – Then, in the icon called“Dynamic labels” you can access different options. Choose and select“Post Date“.
7 – Now you will find a little tool symbol to the left of“Post Date“. When you click on it, two options appear. Select “Post Modified“
8 – For this second date field you add in the“Before” box the text“Updated: ” or“Last updated: “
And that’s it, now you can format the dates to fit the layout of your template and add icons or display them without.
This is what the date looks like here:
Finally you can update any post and check that it runs well and then check if you are alerting search engines in the rich results test.
To do this, you enter the URL of that last post you just updated in this tool and click on “Test URL”
You display the first of the results or, failing that, the one closest to “Article”. If everything is OK, you will see that the date and time of publication is already added and below that of the last modification as you can see in this screenshot.