The WPFolks app is out on iPhone and Android. Free, no ads. Download on the App Store Get it on Google Play
Skip to main content
Login Join
Snippet · PHP

Automatically Add Last Updated Date to WordPress Posts

Shared by Amit Dholiya · September 24, 2026 · @the_content

11 views
1 upvote
Back to Snippets

Show readers when a blog post was last updated instead of only displaying the original publication date. This is useful for tutorials, guides, news, and other content that gets updated regularly.

Steps

  1. Add the code below to your theme’s functions.php.
  2. Save the changes.
  3. Open any WordPress blog post.
  4. The last updated date will appear before the post content.
/**
 * Add last updated date to WordPress posts
 */
function custom_last_updated_date( $content ) {

    if ( ! is_single() || ! is_main_query() || ! in_the_loop() ) {
        return $content;
    }

    $updated_date = get_the_modified_date( 'F j, Y' );

    $output  = '<div class="last-updated-date">';
    $output .= 'Last Updated: ' . esc_html( $updated_date );
    $output .= '</div>';

    return $output . $content;
}

add_filter( 'the_content', 'custom_last_updated_date' );

Tested on

WordPress 6.8

Reported by the author on September 24, 2026. WPFolks has not verified this.

Not tested against WordPress 7.1.3. It may still work.

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