How to Display the Last Modified Date of Your Posts in WordPress for SEO Freshness

If you are searching for this solution you will know that Google loves fresh content and WordPress by default doesn’t allow modified date preference. Rewriting older content making it more relevant to the current time period is a great way to keep your site fresh, relevant and factually correct.   This isn’t only great for your site but also presents a possible SEO boost for date based content, evergreen content which requires regular factual statements to be correct and above all it’s great for user experience.

Most people believe that simply placing a modified date on the post is enough to let Google know a bit of content has been update,  and why shouldn’t it ?.  But that unfortunately isn’t the case, although your sitemap will show a modified date to an updated post, the post will still show its “published date” like in the below image.  The only way Google will show the “updated” time stamp in SERPs is if its the ONLY date shown on the page.  This poses a problem for most WordPress sites because the modified date is very rarely included on any theme or template by default ( unless you have a custom theme by us ).

Google Freshness time stamp - wordpress


So tell us how already….right ?

First we need to locate how the current time stamp ( published date ) is being displayed in your theme,  more often than not you will find it in the single.php template just below the h1 heading,  or for templates such as our custom themes,  we separate the byline to give more flexibility, so ours for example would be in content-byline.php which is called by a loop template.

You will find that something similar to the following code is used by default,  there will be different forms of the same code whether that be difference in date stamp or time but you should be able to identify it relatively easily.

<?php the_time('F j, Y') ?>


<?php get_the_date(); >


<?php the_date(); >


References :

What we would like to do, is use the below modified date stamp,  but only replace the published date stamp above if a modified date exists.  If you were to simply add the code below along side the above date stamps,  Google would only consider the earliest date ( I.e the published date ) :

<?php the_modified_date('l, F j, Y'); >

The Solution…yay..

This is what you’ve been waiting for,  what we have done here is used a conditional. All you need to do is replace your current date stamp code mentioned above with the following to tell WordPress to show the published date….UNLESS there is a modified date,  If there is a modified date, show that instead.

<p class="byline">

<?php if (get_the_modified_time() != get_the_time()) : ?>

		Updated On: <?php the_modified_time('F j, Y'); ?> at <?php the_modified_time('g:i a'); ?>

	<?php else: ?>

		Posted on <?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?>

<?php endif; ?>


If you are struggling to install this code snippet you’re self and/or just want some advice surrounding wordpress and SEO please get in touch.