October 08 2017 0Comment

How to Display the Last Updated Date of a Post in WordPress

(Last Updated On: October 11, 2017)

It is easy to update in WordPress website. Some sites automatically update the date of post publish or update. But if your site don’t do that automatically then no need to worry because in this article we will share you the method to make it auto update.

Post date update is very important for SEO of the site. It also helps to get visitor attraction because always want to get updated stuff. So if your post is updated recently it will attract visitor to click on your post and visit it to read the updated article.Many popular blogs and websites don’t show any date on their articles. This is a bad practice and you should never remove dates from your blog posts.

Displaying Last Updated Date in WordPress:

  1. function wpb_last_updated_date( $content ) {
  2. $u_time = get_the_time(‘U’);
  3. $u_modified_time = get_the_modified_time(‘U’);
  4. if ($u_modified_time >= $u_time + 66400) {
  5. $updated_date = get_the_modified_time(‘F jS, Y’);
  6. $updated_time = get_the_modified_time(‘h:i a’);
  7. $custom_content .= ‘<p class=”last-updated”>Last updated on ‘. $updated_date . ‘ at
  8. $updated_time .'</p>’;
  9. }
  10. $custom_content .= $content;
  11. return $custom_content;
  12. }
  13. add_filter( ‘the_content’, ‘wpb_last_updated_date’ );


This code check if a post’s published date and last modified dates are different. If yes, then it displays last modified date before the post content.


Write a Reply or Comment