BLOGRON BLOGRON COMMUNITY

Author Topic: How to show last updated date of post instead published date in WordPress?  (Read 27 times)

Offline delwar

  • Delwar Jahan
  • Administrator
  • Jr. Member
  • *****
  • Posts: 89
  • Karma: +20/-5
  • I am the Moderator Bitch!
    • View Profile
    • BLOGRON
In your theme/child theme's functions.php file add the following code.

Code: [Select]
/*showing last updated of post instead published date*/
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' );

I do what I love, Money Comes on the Way.