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”.
<?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.