Show Updated Dates on WordPress Posts Only When It Matters

Displaying the last updated date on your WordPress posts can be useful for both readers and SEO, especially when your content is refreshed over time. However, showing an updated date for every small edit can make posts look unnecessarily changed.

This snippet solves that problem by appending the modified date after the published date only when the post was updated at least 30 days after it was originally published.

Instead of replacing your theme’s existing date format, it simply adds the updated date after the published date. That makes it more compatible with many WordPress themes and helps preserve the original design.

Example output:

June 1, 2024 / Updated: August 10, 2024

The main benefits are:

  • Readers can quickly see when an article was meaningfully refreshed.
  • Older evergreen content looks more trustworthy when it has been updated.
  • Minor edits shortly after publishing do not trigger an unnecessary “Updated” label.
  • The snippet works with many themes that use the standard WordPress get_the_date() function.
  • It keeps your published date visible while adding useful freshness information.

This is a simple improvement for blogs, tutorials, documentation sites, and SEO-focused WordPress websites where content freshness matters.

Copy the snippet bellow and add it your teme. Modify as needed.


function your_prefix_append_modified_date_after_published( $the_date, $format, $post )
{

if ( is_admin() ) {
return $the_date;
}

if ( ! $post instanceof WP_Post ) {
return $the_date;
}

if ( ‘post’ !== get_post_type( $post ) ) {
return $the_date;
}

$published_timestamp = get_the_time( ‘U’, $post );
$modified_timestamp = get_the_modified_time( ‘U’, $post );

if ( ! $published_timestamp || ! $modified_timestamp ) {
return $the_date;
}

$days_since_update = ( $modified_timestamp – $published_timestamp ) / DAY_IN_SECONDS;

if ( $days_since_update < 30 ) {
return $the_date;
}

$date_format = $format ?: get_option( ‘date_format’ );
$modified_date = esc_html( wp_date( $date_format, $modified_timestamp ) );

return $the_date . ‘ / ‘ . esc_html__( ‘Updated:’, ‘your-textdomain’ ) . ‘ ‘ . $modified_date;
}
add_filter( ‘get_the_date’, ‘your_prefix_append_modified_date_after_published’, 10, 3 );