Skip to content

Instantly share code, notes, and snippets.

@eksiscloud
Created April 16, 2019 23:41
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 eksiscloud/5b4516813612c53d3a0be4d559b2ed6f to your computer and use it in GitHub Desktop.
Save eksiscloud/5b4516813612c53d3a0be4d559b2ed6f to your computer and use it in GitHub Desktop.
Wordpress, shows last modified date before the content
function my_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 entry-meta"><b>Last updated on '. $updated_date . ' at '. $updated_time .'</b></p>';
}
$custom_content .= $content;
return $custom_content;
}
add_filter( 'the_content', 'my_last_updated_date' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment