Issue:
I have added some custom fields to the add_meta_box and hooked a function to edit_post, publish_post, save_post. Everything is working fine, but unfortunately the autosave destroy all the efforts. I didn’t find any hook to control autosave.
Solution:
I just added a if condition to my hook function. Many of them suggest to increase the autosave time to months/years etc. but I prefer this
This is the condition
a simple hack.
if ($_REQUEST['action'] == 'autosave') return;
So final script looks like below
PHP Script:
add_action( 'save_post', 'save_request_data' );
add_action( 'edit_post', 'save_request_data' );
function save_request_data() {
global $post;
// Will return if it an Ajax Autosave action. We are safe now
if ($_REQUEST['action'] == 'autosave') return;
// ALL YOUR CODES COMES HERE...
}
Hope this will solve your problem with autosave. Thank you

Share Your Thoughts