One of the primary functions of search engines like Google is to provide answers to users’ questions and problems. That’s why it’s important to create content that is helpful and valuable to them, rather than promote your products and services. And frankly, that’s the best way to future proof your business — by focusing on creating value for other people.
This is also the reason why Google loves fresh content. Fresh content doesn’t necessarily have to be new content. Rather, it can be and “old” content, but updated to reflect certain changes; therefore, making it relevant and useful.
And that’s what we’re going to be talking about in this article.
Let me ask you a question.
If you were looking for some resources about how you can install Google Analytics to your website and you came across this one I wrote. What comes to mind?
If I saw that, I’d probably take a look, but I’ll search for a more updated one. Because the contents of that page might not be relevant anymore. Depending on the topic, my leeway would probably be between six months to a year. If it’s older than that, unless it’s the only resource out there, I will probably not take it seriously.
And I believe it goes the same for you. You want something relevant and updated. You don’t want to spend your time reading and following some instructions only to find out later that it’s no longer applicable.
Now, what if you saw the same article and it looks like this…
Now, we’re talking.
Despite it being published a couple of years ago, you see that the date was recently updated.
If you’re using a WordPress website, whether you’re running on the Genesis Framework or another theme, then you can easily make this change yourself. You can do this using a plugin, but I’m biased towards not relying on them, especially if you want to speed up your website and get high 90s score on Google PageSpeed Insights for both mobile and desktop.
Preparatory Points
But before getting into it, I’d like to go through a couple of things.
First, you can simply remove the published date and only show the modified date. In fact, that’s what’s most of the resources out there. They simply tell you how to replace the published date with the modified date. If that’s what you want, there’s absolutely nothing wrong with that approach.
But that’s not what I’m going to here.
As you noticed in the examples above, the dates will be displayed depending on whether or not you actually updated the article. I also included a time element to it.
For example, I published an article on January 1, 2020. The article will display “Published on January 1, 2020.”
A year goes by and I haven’t updated the same article. It will still show the same thing. But if I edited it 6 months after, it will display both dates (or only the modified date which I’ll share below).
But there’s another problem here. Let’s say I noticed a typographical error the day after. I went in and edited the article. The modified date has changed. So, if I don’t include the time element, it will display it both. Again, there’s nothing wrong with that. It’s just weird.
Published on January 1, 2020 • Last Updated January 2, 20120.
Personally, I’d only want to display the modified date only if 30 days or so have passed.
Finally, make sure you make a backup of your site first. While this is relatively simple, a single mistake can make your site inaccessible.
Now that that’s out of the way, let’s dive right in.
How to Show Modified Date Instead of Published Date
There are two variations of this that I will show you.
First, as you saw in the example above, the published date and the modified/last updated date is displayed together.
The other option is to only show the modified/last updated date. Just like this one.
This is actually how it looks like on my website right now. This is option two below.
I’ll show you the code you need to add to your functions.php file for each, then I’ll explain parts of the code in case you want to modify it yourself.
First, login to your WordPress website. Go to Appearance then Theme Editor. Click on the functions.php file then scroll all the way down.
Option 1: Display BOTH Original Published Date and Modified Date
Add this code at the bottom of your functions.php file if you want both the published date and modified date to appear on your posts.
// Published & Modified Date
function be_published_modified_date() {
$date = get_the_date( 'U' );
$updated = get_the_modified_date( 'U' );
$output = '<span class="entry-date"><span class="label">Published on</span> ' . get_the_date( 'F j, Y' ) . '</span>';
if( $updated > ( $date + MONTH_IN_SECONDS ) )
$output .= ' <span class="entry-date-modified"><span class="label">• Last updated</span> ' . get_the_modified_date( 'F j, Y' ) . '</span>';
return $output;
}
add_shortcode( 'be_published_modified_date', 'be_published_modified_date' );
You can edit the text you want by changing the “published on” and “last updated” to whichever you want. Hit save. Then check a post you recently updated but have been originally published a month ago.
Option 2: Display ONLY Modified Date
Add this code at the bottom of your functions.php file if you want only the modified date to appear on your posts.
// Published & Modified Date
function be_published_modified_date() {
$date = get_the_date( 'U' );
$updated = get_the_modified_date( 'U' );
if( $updated > ( $date + MONTH_IN_SECONDS ) )
$output .= ' <span class="entry-date-modified"><span class="label">Last updated</span> ' . get_the_modified_date( 'F j, Y' ) . '</span>';
else {
$output = '<span class="entry-date"><span class="label">Published on</span> ' . get_the_date( 'F j, Y' ) . '</span>';
}
return $output;
}
add_shortcode( 'be_published_modified_date', 'be_published_modified_date' );
Same as above, you can edit the text you want by changing the “published on” and “last updated” to whichever you want. Hit save. Then check a post you recently updated but have been originally published a month ago.
How the Code Works
The code is pretty simple to understand.
For option 1 — display both dates — here’s how to read the code:
- Show original published date
- If the updated date is greater than the original published date + 30, show last updated date.
For option 2 — display only modified date:
- If the updated date is greater than the original published date + 30, show last updated date.
- Else, show original published date
It’s that simple.
Over to You
By displaying the last modified date instead or together with the original published date, you show to your visitors (and Google) that you value them.
You avoid giving them a poor experience by showing them outdated content.
Did you find this helpful? Let me know in the comments below!
20 thoughts on “How to Show Last Modified Date Instead of Published Date on Your WordPress Website”
Hi Ariel,
I went through the whole post and this is probably the only post I read word by word in the last 2 months.
The question2 which I have:
1) Why cannot I add just a text at the top of the post that it was last modified on this date?
2) Secondly, would the provided codes should modified date in the SERP?
Thanks Alexa. That means a lot 😁
1. Because you’ll have to update it manually as opposed to being automatically added/updated.
2. Yes but still depends on google. Some of my posts show the modified date but some show the original published date.
I want to show the Last updated date in place of published. I have added the code in funstions.php but nothing happened.
Can you please guide me?
Hey Bryan, thanks for commenting. There are a couple of things to look at. First, what theme are you using? So your theme might not support this. In the example i shared, i was using the Genesis Framework. Currently, i migrated to Elementor and there is an easier way to do it that’s why in the post you’re seeing, it’s worded as “last updated…”
I m using NewsUp theme, also in my theme it’s not supporting
What should I do?
Thanks in Advance.
What easier way in elementor?
Hi ariel, i have read your explanation, but somehow it doesn’t work with my blog.
Btw my theme is customify, i mean that i can change the post date tobe updated date in the bottom of title
Hello,
Great article! I want to know roughly how much time does it take for google to recrawl the website and show the last modified date in the search results?
It depends. If you want, you can manually submit it for recrawling in google search console. You can do 1) Submit a sitemap and 2) request specific URLs for indexing
Thank you for your response. I did submit the specific URL for indexing and after that Google did crawl the webpage but the published date is still shown in the Search Results. Any Suggestions?
Sometimes this happens. While we can show the modified date as part of UI, it’s Google’s choice to do so in their serp. So that’s out of our control.
One thing to note though, some say that simply modifying a paragraph or two won’t change this date. What’s best is the post is really updated a lot.
Hi Ariel
I have read the article and found it useful to replace my published date with the Last updated date.
I have selected the 2nd option and copy and paste it at the end of the function.php file. But unfortunately, nothing happened.
I am using the Blocksy theme and here is the post URL I tried to implement this method
https://woodnami.com/how-to-remove-oil-stains-from-wood/
I will be thankful if you can advise me, what I am doing wrong.
Thanks
Kenneth
Unfortunately, neither of these code snippets work on my site- but this is exactly what I’m needing right now.
Hi Ariel, great article. However, is there a way to offer a Last Updated data on specific articles? I don’t want it showing on every single post.
Hi Ariel, Great information, I have updated the functions.php file with the same code (The second one) but it is still not showing the Last Updated date on my post.
Many thanks of the instructions and the code.
I got it working in our website with ‘Divi’ of Elegant Themes.
May I know how to show the last modified date in publish date as well in the backend schema on wordpress?
Thank you for this article ! But unfortunately it doesn’t work for me, nothing happens..
I’m using the Sitka theme, so does it mean I can’t do it at all no matter what code I use ? (I tried many codes found on different articles and it never works). It’s so frustrating as it is exactly what I need and want to do :/
It might be worth having a dev look at your theme. Im not a dev either, but from my research, the code i shared uses wordpress basic functionality. If it’s not working and different variations which you mentioned, something in your theme must be conflicting with this functionality.
So it’s either you get a dev to find that conflict and figure it out, or pick a new theme if it’s really important to you. Another alternative is a plugin. Im just not a fan of too much plugins
Hi,
Thanks for the code. It looks good but I’m wondering why you use `add_shortcode` and how to implement this. Usually I see `add_filter` or `add_action`. Hoping you can add some more explanation to your article about this. Thanks!