How to show when the last time the whole WordPress site was updated rather than just the current page

A customer wanted to show visitors when the last modification to the whole wordpress site was on the home page. There’s a function in WordPress which give you the function to the current post or page which is :

the_modified_time('F j, Y');

However to find out the whole site, you need to do the current MySQL Query :

$last_site_update = $wpdb->get_var( "SELECT post_modified FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified DESC LIMIT 1" );

Then you can formulate it with PHP’s Date Function e.g. : echo date(‘F j, Y’, strtotime($last_site_update));

 

 

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...