I want to display the date of the last date the post was updated on my WordPress site

asked Dec 10, 2012 in Website Builder by SunFun (3,000 points)
Hi there,
As mentioned in my title, I would like to add the date of the last update to a post in my WP site. Something like  Last Updated : December 15,2012. And I want it to be displayed somewhere in the header.
 Does anyone know how to do this?
I would really appreciate your help
Many thanks
commented Dec 10, 2012 by SunFun (3,000 points)
thank you all..

3 Answers

0 like 0 dislike
answered Dec 10, 2012 by expert (14,380 points)
Accessing the database directly you can find the latest post update.
<?php $latest = $wpdb->get_row("select post_modified from $wpdb->posts
where post_type in ('post', 'page') and post_status ='publish' order by post_modified desc");
 echo mysql2date('m/d/Y',$latest->post_modified);
0 like 0 dislike
answered Dec 10, 2012 by WebProX (12,200 points)
You can use the_modified_date() inside your loop you
<?php the_modified_date( 'F j, Y', 'last updated: '); ?>
Check this http://codex.wordpress.org/Function_Reference/the_modified_date
0 like 0 dislike
answered Dec 10, 2012 by WebGuru (9,280 points)
If you want  the last modified date  do this
<strong>LAST UPDATED On</strong>: <?php
$last_updated_on = get_posts('posts_per_page=1&orderby=modified');
foreach( $last_updated_on as $post ) { setup_postdata($post); the_modified_date(); }