Display last updated date on articles

It’s a great idea to include the Published Date and Last Updated date on content you update regularly. This will let your readers know the content isn’t out-dated.

WordPress stores a published date and modified date for every post on your site.

You can use Limit Modified Date to make minor changes to an article (like fixing a typo) without changing the modified date.

There are a few ways you can display the modified date on your articles.

A Shortcode Option

If you’re using a Genesis theme, you can use shortcodes in the Post Info and Post Meta areas to display dynamic content (more information).

Genesis includes shortcodes for both the published date ([post_date]) and the modified date ([post_modified_date]). Here’s a full list of the available Genesis shortcodes.

But if you use the shortcode for modified date, it will always appear, even if it’s the same as the published date.

I personally prefer to only show the modified date if it’s more than a week later than the published date.

Add the code below to your theme’s functions.php file, or a core functionality plugin. You can then use [be_published_modified_date] to display the published date, and include the modified date if it’s more than a week later.

 * Published & Modified Date
 * @see https://www.billerickson.net/display-last-updated-date-on-articles/
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 + WEEK_IN_SECONDS ) )
		$output .= ' <span class="entry-date-modified"><span class="label">Updated on</span> ' . get_the_modified_date( 'F j, Y' ) . '</span>';

	return $output;
add_shortcode( 'be_published_modified_date', 'be_published_modified_date' );

A Code Option

If you prefer including the code directly in your theme, include the same code listed above.

Then add the following to your theme file (ex: single.php) where you’d like the published and modified date to appear.

echo be_published_modified_date();

Genesis Theme Framework WordPress Development

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk

Reader Interactions

Leave A Reply