Update post date to modified date automatically

Doing what you ask is remarkably easy.

function reset_post_date_wpse_121565($data,$postarr) {
  // var_dump($data,$postarr); die; // debug
  $data['post_date'] = $data['post_modified'];
  $data['post_date_gmt'] = $data['post_modified_gmt'];
  return $data;
}
add_filter('wp_insert_post_data','reset_post_date_wpse_121565',99,2);

I answer with hesitation though. As in my comment, if you are using dates in your permalinks you will generate broken links every time that post_date changes.

The real problem in your case seems to be the design of the “expirator” plugin which would mean that the proper solution might be to redesign that plugin, or find a filter that it provides, instead of altering something like the post date (which has consequences).

Leave a Comment