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);
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);
add the code to theme functions.php or create a plugin,
upload to wordpress read more at create wordpress custom plugin
<?php
/*
Plugin Name: test plugin
Plugin URI: https://www.test.com
Description: A short little description of the plugin.
Version: 1.0
Author: test
Author URI: https://www.text.com
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: wp
Domain Path: /languages
*/
Mandatory fileds
<?php
/*
Plugin Name: test Tutorial
Plugin URI: https://www.tt.com
Version: 1.0
*/
<?php
/*
Plugin Name: Auto date change on update
Plugin URI: https://www.rajuginni.com
Version: 1.0
*/
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);
in windows new notepad.txt after saving >> windows file explorer view settings select show file extensions. then change .txt to .php.
paste it in a.php file and zip and upload
make sure to disable if brokens.
Tested its working
edited old post, and clicked on update then it automatically changing to the current date.
please share my 30+ minutes work.
Troubleshooting:
When you use post permalinks with year/month format (it will broke becuase date changes month of url also changes.)
If you edit attachment pages they will aslo changes to the current date.