Skip to content

Instantly share code, notes, and snippets.

@WordBits
Created June 6, 2019 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WordBits/6104a2828c6352998fdd442d0e44229e to your computer and use it in GitHub Desktop.
Save WordBits/6104a2828c6352998fdd442d0e44229e to your computer and use it in GitHub Desktop.
<?php
// Download this snippet as a plugin and more at: https://wordbits.io/snippet/display-the-last-updated-date-of-posts/
// Created by: Liam Dempsey
?>
<?php
function wpb_last_updated_date( $content ) {
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time('F jS, Y');
$updated_time = get_the_modified_time('h:i a');
$custom_content .= '<p class="last-updated">Last updated on '. $updated_date . ' at '. $updated_time .'</p>';
}
$custom_content .= $content;
return $custom_content;
}
add_filter( 'the_content', 'wpb_last_updated_date' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment