0

I need disable auto save with function.php in wordpress. What should I do? Thanks

1 Answer 1

0

There are a few methods to disable autosave/revisions.

Disabling autosave:

  1. Using action and dequeuing the .js that is responsible for autosave, this goes into functions.php, located in the current theme directory.
function bt_disable_autosave () {
    wp_deregister_script('autosave');
}
add_action('admin_init', 'bt_disable_autosave');
  1. Using a constant to set the interval so high (one day) it will never happen unless you leave the browser open for that long, this goes into the wp-config.php, located in the root of the wordpress install.
define('AUTOSAVE_INTERVAL', 86400);

Disabling/limiting revisions:

  1. Limiting revisions using a constant, this goes into the wp-config.php, located in the root of your wordpress install.
define('WP_POST_REVISIONS', 3);
  1. Disabling revisions, this is the same as the above, you just set it to 0 instead.
define('WP_POST_REVISIONS', 0);
// or
define('WP_POST_REVISIONS', false);
4
  • hey Buttered_Toast Thank you :) I used the first option and that does not work I would like to add the code to functions.php any idea why it is still autosaving? Commented Jun 22, 2022 at 8:52
  • Did you add it to the active theme functions.php? it's a better idea to create a child theme if you plan on adding custom code, that way next time the theme is updated you wont lose your custom code. Commented Jun 22, 2022 at 8:59
  • hey Buttered_Toast yes I added to child theme functions.php but still autosave is happening! can you help? Commented Jun 22, 2022 at 9:05
  • How do you know it's not working. I just pasted this code into my fresh wp install and the autosave is dequeued, how are you checking that your code works? Commented Jun 22, 2022 at 9:41

Your Answer

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

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