Hongmu Notes
Home Program Notes How do I disable revisions and automatic draft saving in WordPress?
Program Notes wordpress

How do I disable revisions and automatic draft saving in WordPress?

How do I disable revisions and automatic draft saving in WordPress?

WordPress automatically tracks revisions of posts; every time you edit a post, a record is logged in the后台, and each revision is inserted as a separate entry into the posts table.

Due to the intervention of article revision and automatic saving, the article ID often becomes larger.

While this may not cause significant issues for your WordPress site's performance, an excessive number of article versions can place a heavy burden on your server resources and database, leading to slower database queries.

Disable the WordPress version revision feature and turn off automatic draft saving.

1. Before disabling this feature, manually delete all existing article version revision records from the database.

DELETE FROM wp_posts WHERE post_type ='revision'

2. Disable article revision and auto-save features

To make the change, add the following code before the `require_once(ABSPATH. '"wp-settings.php"');` line in `wp-config.php`:

//取消修订
define('WP_POST_REVISIONS', false);
// 设置自动保存间隔,单位是秒,默认60 ,false则不保存
define('AUTOSAVE_INTERVAL', false );

ad1a1b7183091049

Alternatively, you can add the following code to your theme's `functions.php` file; then refresh the webpage to delete all old revision versions.

$wpdb->query( "DELETE FROM $wpdb->posts WHERE post_type = 'revision'" );

The detailed configuration for the constant `WP_POST_REVISIONS` is as follows:

`true` (default) or `-1`: Indicates saving all revision versions;
`false` or `0`: Indicates that no additional version will be saved (except for the automatically saved version);
Positive integer n: Represents saving n revision versions (+1 saves the auto-save version); older versions will be deleted.

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

What should I do if the Redis Object Cache plug-in cannot be linked after wordpress redis changes the password?

What should I do if the Redis Object Cache plug-in cannot be linked after wordpress redis changes the password? Program Notes wordpress

Problem description: My wordpress site server uses pagoda panel, installed php8.0, and installed redis on the extension panel, and installed Redis Object Cache plug-in in wordpress. In fact, in general, you don't need to do anything, just start it directly. However, it is unsafe for radis not to set a password, which is a risky loophole, so I still think it is better to set a password, …
👁 255
Detailed Tutorial on Migrating EmpireCMS Blog Data to WordPress

Detailed Tutorial on Migrating EmpireCMS Blog Data to WordPress Program Notes wordpress

PS1: Second revision – now supports data transfer between categories, posts, and tags. PS2: If the post IDs consistently don't match, you can try clearing the WordPress post category data table and relationship tables. I previously used Typecho for my blog, but later migrated to Empire; however, Empire has too many features – using it for a blog feels like putting a large hammer into a small hole! Additionally, I often record important code snippets in my blog – all of which I've painstakingly written...
👁 546
WordPress issue: pages freezing due to image transcoding

WordPress issue: pages freezing due to image transcoding Program Notes wordpress

Last night, while uploading an image, for some reason, the uploaded image was automatically transcoded. Transcoding type: BASE64 encoding. For an image on a website, simply upload it to your server and then access the link – the image will then be displayed. However, there is another approach: directly transcoding the image; then you can simply access the converted image using its encoded URL. Problem description: When an image is relatively small (e.g., only a few KB in size), transcoding it and then hosting it on a website can help avoid...
👁 152
WordPress database query operations

WordPress database query operations Program Notes wordpress

To connect to a database for a WordPress installation, you need to include the `wp-config.php` file in your PHP script. This file contains the database configuration details for WordPress installation and other constants. Here is a simple example demonstrating how to include the `wp-config.php` file and establish a database connection: // Include the wp-config.php file: require...
👁 378
WordPress MySQL Database Table and Subtable Structure Functionality Guide

WordPress MySQL Database Table and Subtable Structure Functionality Guide Program Notes wordpress

WordPress uses a MySQL database. Its data table structure differs slightly from that of conventional databases; data can be stored either in the form of standard data tables or as data elements – the latter approach is less intuitive when viewed directly. To become a developer, you must understand the basic structure of the WordPress database and be able to use it within your own plugins or themes to write to or read from the database. I. Data Tables – As of WordPress...
👁 374

Recommended reading

(PC+WAP) – Marketing-oriented website template for building energy efficiency shading solutions (pbootCMS); Download source code for energy-efficient building websites – 0724

(PC+WAP) – Marketing-oriented website template for building energy efficiency shading solutions (pbootCMS); Download source code for energy-efficient building websites – 0724 Practical Collection pbootcms Template

A marketing-oriented PbootCMS website template for building energy efficiency and shading products, compatible with both PC and mobile devices. The design features a fresh, eco-friendly aesthetic that emphasizes energy conservation and environmental sustainability. The page highlights shading products, energy-saving solutions, and project cases, enabling building energy efficiency companies to efficiently acquire online customers and showcase their technical advantages. Template Preview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extract...
👁 40
Empire CMS personal blog articles news information responsive HTML5 responsive mobile template 053

Empire CMS personal blog articles news information responsive HTML5 responsive mobile template 053 Practical Collection empire template

The template uses the new version of Empire CMS as its core. The whole site design is high-end and simple, and the SEO is reasonable! Suitable for personal blogs, information, articles, adaptive mobile phones and other tablet devices! All modifications are managed in the background! Easy and fast! The whole site list adopts the drop-down loading method. For SEO reliability, the automatic drop-down loading method and the real paging source code are used! Preview image decompression password 🔒 Hidden content: View after commenting If there is no password prompt on the download page, the password defaults to...
👁 1646
Responsive Vocational Education Website Template 0851

Responsive Vocational Education Website Template 0851 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for the vocational education sector, featuring a professional design style that effectively showcases vocational education courses, training programs, employment services, and faculty resources. It helps vocational training institutions attract learners online and enhance their brand awareness. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS...
👁 45
(Adaptive Mobile Version) Water Sports Equipment PBootCMS Website Template – Download Source Code for a Diving Service Company Website – 0725

(Adaptive Mobile Version) Water Sports Equipment PBootCMS Website Template – Download Source Code for a Diving Service Company Website – 0725 Practical Collection pbootcms Template

A PbootCMS website template for water sports equipment and diving services, compatible with both PC and WAP devices. Its clean and dynamic design is ideal for showcasing diving gear, water sports equipment, and training services. This template helps outdoor sports companies attract extreme sports enthusiasts online. Template Preview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn | Related Articles...
👁 52
Responsive children's education website template 0852

Responsive children's education website template 0852 Practical Collection Yiyou template

An eyouCMS responsive website template designed for the children's education sector. Its vibrant and child-friendly design is ideal for showcasing children's education courses, early childhood education programs, faculty expertise, and teaching achievements. This template helps children's education institutions attract parents online and enhance their brand image. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for eyouCMS | eyouCMS...
👁 33
(Adaptive mobile version) PBootCMS template for micro-business supply chain websites – Download e-commerce and micro-business agency website templates – 0726

(Adaptive mobile version) PBootCMS template for micro-business supply chain websites – Download e-commerce and micro-business agency website templates – 0726 Practical Collection pbootcms Template

A PbootCMS website template designed for WeChat business suppliers and online store agents, compatible with both PC and WAP devices. Its practical information-flow design is ideal for showcasing WeChat business products, agent policies, and supply chain information. This template helps WeChat business platforms or supplier websites attract agents and distributors online. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn | Related Articles...
👁 50