Last active
September 14, 2018 21:54
-
-
Save ThemeMetric/8880a7df282cd7442b026324277d712b to your computer and use it in GitHub Desktop.
Show Last Modified Date in WordPress post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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