I would like to be able to post the most recent updated date in my footer. However, I can't seem to find a way to do that globally for the site, just for each post/page at a time using get_the_modified_date().

So for example if I make a change to my home page the footer would be updated to that date and time. If I later make an edit to a miscellaneous page, then the "Updated" date and time would change to reflect that more recent update.

Any help is greatly appreciated.


I don't know if there's a more WP-friendly way to do this, but this query will do what you want. It gets the latest date from the posts table for any post or page:

select max(post_modified) from wp_posts where post_type IN ('post', 'page');

So you could wrap that up in a shortcode for example, like:

function get_latest_update_date() {
  global $wpdb;
  return $wpdb->get_var("select max(post_modified) from wpposts where post_type IN ('post', 'page');");

add_shortcode('latestupdatedate', 'get_latest_update_date');

If you want to format the date, you'll need to add the PHP date parsing/formatting functions.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.