Skip to content

Instantly share code, notes, and snippets.

@JamesVanWaza
Last active November 14, 2021 23:27
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 JamesVanWaza/2f2fe1c9814f8ef646fd01955aa2fdf2 to your computer and use it in GitHub Desktop.
Save JamesVanWaza/2f2fe1c9814f8ef646fd01955aa2fdf2 to your computer and use it in GitHub Desktop.
Wordpress: Last Updated On
<?php
function display_last_updated_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">This page was last updated on '. $updated_day . ' at '. $updated_time .'</p>';
}
$modified_content .= $content;
return $modified_content;
}
add_filter( 'the_content', 'display_last_updated_date' );
.last-modified{
background-color: burlywood;
color: black;
text-transform: uppercase;
font-size: 0.8em;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment