Posted by & filed under WordPress.

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *