A blog post is something you do not typically go back and edit. It’s a one and done piece of content. However, sometimes there is a reason to go back and change content in a post, or more likely, to update the content on a page.
I like my visitors to know the last time I made a content update. It shows that I am actively managing the content on my site. Here is a code snippet that will show the updated modification time for a post/page, as well as the original publish time.
<?php if (get_the_modified_time() != get_the_time()) : ?> <p>Posted: <?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?>, Last Updated: <?php the_modified_time('F j, Y'); ?> at <?php the_modified_time('g:i a'); ?></p> <?php else: ?> <p>Posted: <?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?></p> <?php endif; ?>
This snippet is really simple. If the modified time is not equal to the original post time, then show the original publish time followed by the modified time. If the post or page hasn’t been updated since it was orginally published, then the visitors will just see the original publish time.
5 thoughts to “Show the Latest Update Time and Date for a WordPress Page or Post”
This works fine but on my WordPress website it is showing different update dates on different pages. Why is it like that.
The update date is relative to each post and page.
I am new to this how to make web pages and working for a client who wants to show when the webbsite was last updated. You have written a code for this, but exactly where do I insert the code?
Would be nice if you had the opportunity to respond.
Thank you for posting this! Very clean and useful.
I was looking for this only. Simple concept and excellent user experience.