rveitch
4/19/2016 - 7:31 PM

set_lastupdated_to_lastpostdate.php

set_lastupdated_to_lastpostdate.php

<?php

function set_lastupdated_to_lastpostdate( $wpdb_blogid ) {

  switch_to_blog( $wpdb_blogid );

  $lastpostdate = get_lastpostdate( 'blog' );

  // Update the last_updated time
  update_blog_details( $wpdb_blogid, array('last_updated' => $lastpostdate ) );

  echo 'Last Post Date for site ' . $wpdb_blogid . ' Updated to: ' . $lastpostdate . '<br>';
  echo 'Last Updated Date for site ' . $wpdb_blogid . ' is currently: ' . get_blog_details( $blogId )->last_updated;


  restore_current_blog();
}

# Debug bar test
set_lastupdated_to_lastpostdate( '11' );