Posted By

selfmadepsyche on 02/17/09


Tagged

wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tobiasmay


Showing A Last Modified Date on Your WordPress Posts


 / Published in: PHP
 

URL: http://wphacks.com/how-to-show-last-modified-wordpress-post/

If you run a blog where posts are regularly updated, you may want to consider updating your post meta data to also reflect the last modified date when applicable, rather than showing just the original posting date.

  1. Look for the code that displays the post date. It should look something like the following:
  2.  
  3. Posted on: <?php the_time('l, F jS, Y') ?>
  4.  
  5. Now replace it with the following code (slightly modified from Ardamis’ post):
  6.  
  7. Posted on <?php the_time('F jS, Y') ?>
  8. <?php $u_time = get_the_time('U');
  9. $u_modified_time = get_the_modified_time('U');
  10. if ($u_modified_time != $u_time) {
  11. echo "and last modified on ";
  12. the_modified_time('F jS, Y');
  13. echo ". "; } ?>

Report this snippet  

You need to login to post a comment.