Skip to content

Instantly share code, notes, and snippets.

@ThemeMetric
Last active September 14, 2018 21:54
Show Gist options
  • Save ThemeMetric/8880a7df282cd7442b026324277d712b to your computer and use it in GitHub Desktop.
Save ThemeMetric/8880a7df282cd7442b026324277d712b to your computer and use it in GitHub Desktop.
Show Last Modified Date in WordPress post
// Pest this code snipest in theme functions php file
function show_last_modified_date( $content ) {
$original_time = get_the_time('U');
$modified_time = get_the_modified_time('U');
if ($modified_time >= $original_time + 86400) {
$updated_time = get_the_modified_time('h:i a');
$updated_day = get_the_modified_time('F jS, Y');
$modified_content .= '<p class="last-modified">Last updated on '. $updated_day . '</p>';
}
$modified_content .= $content;
return $modified_content;
}
add_filter( 'the_content', 'show_last_modified_date' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment