Show last time WordPress site was updated / modified

This is a very simple query of the $wpdb->posts table.

$last_update = $wpdb->get_var("
  SELECT post_date 
  FROM {$wpdb->posts} 
  WHERE post_type IN('post','page') 
  AND post_status="publish"
  ORDER BY post_date DESC LIMIT 1"
);
var_dump($last_update);

You could do the same thing (similar) with …

$args = array(
  'post_type' => array('post','page'),
  'posts_per_page' => 1,
);
$last_updated = new WP_Query($args);
var_dump($last_updated->post->post_date);

… but that may well be overkill just to get the most recent date.

Leave a Comment