I need display last modified date of most recent modified post in out of loop.

  • 1
    What have you tried so far? Where do you want to display the date - front end or back end? On what page/archive/content type?
    – WebElaine
    Jan 9, 2020 at 14:15
  • If you haven't seen the top related question then there's a nice answer there too, saving the last modified date in options.
    – Rup
    Jan 9, 2020 at 15:29

1 Answer 1


This works for me. Place this in your functions.php file:

function prefix_last_modified_date() { 
  $last_modified_date = null;

  $args = array(
    'post_type'  => 'post', // could be page, or a CPT
    'orderby'    => 'modified',
    'post_count' => 1,

  $last_modified = new WP_Query( $args );

  if ( $last_modified->have_posts() ) {
    $last_modified_date = get_the_modified_date();


  return $last_modified_date;

Then you can display the last modified post date anywhere in your theme:

echo prefix_last_modified_date();


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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