Skip to main content
Login Join
Snippet · PHP

Auto Add “Last Updated” Date in Posts

Shared by Darshit Rajyaguru · May 19, 2026 · @the_content

40 views
1 upvote
Back to Snippets

Automatically shows the updated date after post content.

function dr_display_last_updated_date( $content ) {
    if ( is_single() ) {
        $updated_date = get_the_modified_date( 'F j, Y' );

        $content .= '<p class="post-updated">';
        $content .= 'Last Updated: ' . esc_html( $updated_date );
        $content .= '</p>';
    }

    return $content;
}
add_filter( 'the_content', 'dr_display_last_updated_date' );
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments