The perfect method for wordpress to disable document revision and automatic saving is automatically saved by wordpress.

Source: Internet
Author: User
Tags wordpress version

The perfect method for wordpress to disable document revision and automatic saving is automatically saved by wordpress.

Wordpress's article revision and automatic saving functions have been annoying for so long. You have also used the super switch plug-in to disable wordpress Article revision and automatic saving, however, there are already enough plug-ins in your blog, so you have to modify the wordpress main program to disable Article revision and automatic saving. However, a bad thing about this method is that every time you upgrade wordpress, you have to change the wordpress source code again, which is really troublesome. I accidentally hit the ZWW blog today and found this non-plug-in-free source code to implement wordpress's method of prohibiting article revision and automatic saving. Let's share it with you!

The usage is simple. You only need to add the corresponding code in functions. php In the topic directory. The Code is as follows:

Copy codeThe Code is as follows:
/* Remove auto save and revision */
Remove_action ('pre _ post_update ', 'wp _ save_post_revision ');
Add_action ('wp _ print_scripts ', 'Disable _ autosave ');
Function disable_autosave (){
Wp_deregister_script ('autosave ');
}

Test environment: WordPress 3.1.2, which is supported by more than 3.0 of the principle.


How to solve the disconsecutive id of a Post published by wordpress38

If you are not particularly concerned about it, it doesn't matter if you are not continuous. This article does not make much sense to you.
I. Disable document revision
The so-called revision of an article means that every time you modify an article, it will automatically help you save and modify the previous article version. The term is version control, this ensures that the previous content can be restored by mistake, which is of great help in the maintenance of Wiki documents, but as a small blog, it seems to be of little use, and this revision occupies an ID in the database, which is also one of the problems that lead to the Document ID inconsistency. To disable the article revision, you can add in the wp-config.php file:

1

Define ('wp _ POST_REVISIONS ', false );

Ii. Delete the document revision
After the document revision is disabled, the database still saves the previously created document revision, which is of little use and occupies the ID. We can delete it. You can execute the following SQL statement (back up) in phpmyadmin ):

12345

DELETE a, B, cFROM wp_posts aLEFT JOIN wp_term_relationships B ON (. ID = B. object_id) left join wp_postmeta c ON (. ID = c. post_id) WHERE. post_type = 'revision ';

3. Delete unnecessary attachments
I believe that many bloggers will upload/insert some attachments, such as videos and music, at the same time when publishing articles. These attachments can be seen in the WordPress management background-media library, different Media correspond to different articles. However, you should note that these media files also occupy the Document ID, which is stored in the same database table wp_posts as the document. If you are pursuing a perfect continuous Article ID, do not upload or insert the media when publishing the article. In the WordPress management background-media repository, delete previously uploaded media (note that this operation is not only about deleting records, but also deleting uploaded files). If necessary, use FTP to upload these files again.
4. Disable auto save
The advantage of automatic saving is that when you edit an article, the system will automatically save the edited article at every short time to prevent the webpage from being suddenly closed, as a result, thousands of words have been written before. The disadvantage is that every article will have an automatically saved record, which also occupies an article ID, which is also one of the reasons for the Document ID inconsistency. If you do not need this function, in the following two files:

12

Wp-admin/post-new.phpwp-admin/post. php

Comment out this line:

1

// Wp_enqueue_script ('autosave ');

5. Rearrange discontinuous Article IDS
The following methods do not support the latest WordPress version. After completing the above four steps, we can basically ensure that all the post IDs that will be released in the future will be continuous. However, the IDs of previously published articles are still in disorder and we have to rearrange them, to ensure that the ID is continuous. I wrote a PHP script. You can download it at the following URL, open it in a text editor, modify the database information according to the instructions at the beginning, and then upload the PHP file to your blog space, run the command and you can see OK. You can go to phpmyadmin to check whether the IDs in the wp_posts table are continuous. Back up your database before you start. (If you use post id as a fixed link, it may change the URLs of all articles, which may affect search engine indexing. If you use a plug-in to create a new database table, such as the voting plug-in, problems will also occur. If you create a parent-child relationship page in your blog, the relationship will be lost if you run the following script. Please use it with caution !)... Remaining full text>

How can I disable automatic saving of drafts in wordpress?

Just add the following code to the wp-config.php:
Copy the Code as follows:
Define ('autosave _ INTERVAL ', 120); // sets the Automatic Storage INTERVAL in seconds. The default value is 60.
Define ('wp _ POST_REVISIONS ', false); // disable the article revision function.
Define ('wp _ POST_REVISIONS ', 3 );//

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.