I need disable auto save with function.php in wordpress. What should I do? Thanks
1 Answer
There are a few methods to disable autosave/revisions.
Disabling autosave:
- 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');
- 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:
- 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);
- 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);
-
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