Display the Last Updated Date of Your Posts in WordPress

Wordpress is used by millions of  bloggers for many purposes, Many NEWS site's also use wordpress, If you have a NEWS WordPress blog whenever you update a news post you might also want your users to get the date updated on your post.
In this tutorial we will share how you can let your users know that the post was updated. We will highlight how to display the last updated date of your posts.

For example, if you posted an article on May 9, 2014, and you found out three days later that there was an update to the story. You can just edit the article, and it will show May 12, 2014 at the timestamp for last update.

First you need to open and check all these these files:

  1. index.php
  2. single.php
  3. page.php
Then you will need to find the following code:

<?php the_modified_time('F jS, Y');?>
Replace the code above with :
<?php $u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 86400) {
echo "and last modified on ";
the_modified_time('F jS, Y');
echo " at ";
the_modified_time();
echo ", "; } ?>

FAQ 

Q. Why i cant find the code in my theme ?
A.  1. there are so many formats of displaying dates, you might not see the exact code. But try to find a similar code.
     2.There are many different WordPress Themes, Theme Frameworks, and child themes. You should ask in the support forums for your theme and they will let you know how you can add your custom code to the theme.


Comments

Popular posts from this blog

Show Full Post on Front Page of Ghost, Not Excerpt

Video Blogger Templates

5 Beautiful Dark Blogger Templates