change the post date

How To Change The Post Date To Recently Updated Date?

In today’s post, I will share with you all how to display your recently updated post date automatically as you update your content. Currently how WordPress is set once you publish a post, it displays the time and date you have published that post depending on your setup. The issue I find with that is if you have content that needs to be constantly updated like we do at 85ideas then standard WP format is not the best practice. For example, this very post was written in 2019 but a year from now the WordPress core code could have changed and we would then update this post to let you know this information is still up to date.

 

Ok, so without further ados lets look at the code we need to make this happen. I must stress especially for beginners to backup your site first before making any changes.

First you need to open these three files:

  • index.php
  • single.php
  • page.php

Then you will need to locate the following code:

<!--?php the_modified_time('F jS, Y');?-->

Note: Since there are so many formats of displaying dates, you might not see the exact code, but something along this line.

Replace it with:

 <?php $u_time = get_the_time('U');
 $u_modified_time = get_the_modified_time('U');
 if ($u_modified_time >= $u_time + 86400) {
 echo "Last updated on ";
 the_modified_time('F jS, Y');
 echo ", "; } 

 else {echo "Posted on "; the_time('F jS, Y');} ?>

Why would you even want to go to such measures to just to have your site to show the last updated post? This helps tremendously with your user experience as there can be pretty confident the article they are using is still relevant and up to date. Another added bonus is that the simple small change can help with SEO because the search engines know your content is still relevant.

What other alternatives is there?

You could simply remove your date completely, but depending which niche you are in this can have a real negative effect. I run another beauty blog on the side and we do not use dates on that site because our writer for that site shares hair and makeup tips that should still work many years to come.

Another alternative to removing the date or setting it up to automatically change the date to the recently updated is changed the publish date to the current time in editing.

Whichever option you choose is totally up to you, let me know if this article helps you out at all in the comments below or help us by sharing it on.

*last updated 03/11/2019

Tags:
Editorial Staff
flytonic.info@webfactoryltd.com

Editorial Staff at 85ideas is a team of WordPress experts led by Brian Harris. Here to share amazing tuts, guides and collections.

2 Comments
  • Dale Reardon
    Posted at 08:22h, 26 May Reply

    Great article but I hate editing theme files. I know it is an older plugin but here is a plugin that automatically updates the publish date for you when you update / edit / save the post / page again. I just installed it with WP4.5.2 and it still works fine:

    Dale.

  • Onome Joseph
    Posted at 08:31h, 03 May Reply

    Nice edit, but I was eon dering if there could be a plugin fir this. I really don’t want to touch my raw files.

Post A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.