👋🏼Welcome to my WP-Host blog where I am excited to share my knowledge and expertise on WordPress hosting and website construction tutorials with you. Let’s connect and learn from each other! You can reach me at info@yrshare.com.
WordPress disable or clean revisions with autosave: By default, WordPress saves a draft or revision every 1 minute. Over time, this results in a large number of IDs being occupied by these drafts, causing many of our article IDs to be non-consecutive and have gaps in between. Furthermore, this leads to accumulation of database junk over a long period of time, ultimately affecting the website’s loading speed. In the following text, I will provide several solutions to address this issue.
Users who use wordpress to build a website may love or hate the built-in modified version and automatic draft function. These two functions are actually quite useful, especially the automatic draft function. If you accidentally close the webpage while writing an article, you can directly find the article you just wrote in the draft. But most users still don’t like it, so you might consider turning it off.
Method 1
If you don’t want the wordpress site to automatically save or produce a modified version when writing an article, you can use the following code to disable it.
code 1
//禁用文章自动保存
add_action('wp_print_scripts','disable_autosave');
function disable_autosave(){
wp_deregister_script('autosave');
Directly disabling revisions and auto-saving is actually not a very good way, because these two functions are quite useful, as long as we can clean up useless revisions and auto-save in time, so we can use wordpress plug-ins to To achieve this effect, the plugin recommended here is WP-Optimize.
WP-Optimize
https://wordpress.org/plugins/wp-optimize/
After installing the WP-Optimize plugin, revisions and autosaves can be cleaned up separately in the settings.
【WordPress Hosting / 悦然wordpress建站】I am a WordPress hobby from China, and I like to communicate with friends from all over the world to learn WordPress website building and maintenance related knowledge.