Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Last updated date shortcode

Type [last_updated] in a post or page and it shows the date it was last changed, like “Last updated: 12 March 2026”.

  • Type PHP
  • Runs Where you put the [last_updated] shortcode
  • Category Shortcodes
  • Tested with WordPress 7.1
PHP
<?php

// [last_updated] or [last_updated label="Updated on"]
$atts = shortcode_atts( array( 'label' => 'Last updated:' ), $atts, 'last_updated' );
$post = get_post();
if ( ! $post ) {
	return '';
}
return sprintf(
	'<span class="last-updated">%s <time datetime="%s">%s</time></span>',
	esc_html( $atts['label'] ),
	esc_attr( get_the_modified_date( 'c', $post ) ),
	esc_html( get_the_modified_date( '', $post ) )
);

Good to know

Change the text with [last_updated label="Updated on"].

How to use it

Type [last_updated] in a post, a page or a Shortcode block.

In these packs

  • Shortcodes: Handy shortcodes for dates, breadcrumbs, buttons, share links, members-only content and more.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.