Web Hosting Geeks | Web Hosting Experts
Need help? Call us 1(866)TOP-HOST

14611 reviews 1734 hosting providers

Questions & Answers

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

Dec 10, 2012 by SunFun
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
thank you all..

3 Answers

0 votes
Dec 10, 2012 by expert
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 votes
Dec 10, 2012 by WebProX
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 votes
Dec 10, 2012 by WebGuru
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(); }