Table of Contents
Last updated date in WordPress
There are a few methods to display last updated in WordPress
Change post date to last updated date
But default, post date is published date, if like to change it to last updated date, add additional CSS as below.
/* for post modified */
.entry-date.published { display: none; }
.updated:not(.published) { display: inline-block; }
/* for post that never been modified, theme uses .updated */
.entry-date.published.updated { display: inline-block; }
Change functions.php
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">Last updated on '. $updated_date . ' at '. $updated_time .'</p>';
}
$custom_content .= $content;
return $custom_content;
}
add_filter( 'the_content', 'my_last_updated_date' );
Change template-tags.php
This is the PHP way to modify the code to display dates.