Table of Contents
The perfect way to implement wordpress prohibiting article revision and automatic saving, wordpress automatically saves
How to turn off the automatic draft saving function in wordpress?
Home Backend Development PHP Tutorial How to perfectly implement wordpress prohibiting article revision and automatic saving, wordpress automatic saving_PHP tutorial

How to perfectly implement wordpress prohibiting article revision and automatic saving, wordpress automatic saving_PHP tutorial

Jul 13, 2016 am 10:15 AM
wordpress prohibit Auto save

The perfect way to implement wordpress prohibiting article revision and automatic saving, wordpress automatically saves

After using WordPress for so long, I have always hated the article revision and auto-save functions of WordPress. I have also used the super switch plug-in to disable the article revision and auto-save functions of WordPress. However, my blog already has enough plug-ins, so I had to modify WordPress. The main program is used to implement the functions of prohibiting article revision and automatic saving. But the disadvantage of this method is that every time WordPress is upgraded, the WordPress source code must be modified again, which is really troublesome. Today I accidentally bumped into the ZWW blog and found this non-plug-in-free source code method to implement wordpress's prohibition of article revisions and automatic saving. Share it with everyone!

The method of use is very simple, just add the corresponding code to functions.php in the theme directory. The code is as follows:

Copy code The code is as follows:

/* Remove automatic saves and revisions */
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, in principle, all versions 3.0 and above are supported.

How to solve the problem of discontinuous IDs in wordpress38 published articles

If you don’t particularly care, even discontinuity is irrelevant, and this article won’t make much sense to you.
1. Disable article revision
The so-called article revision means that every time you modify an article, it will automatically save the article version before modification for you. The professional term is called version control, which ensures that the article is modified by mistake. In some cases, the previous content can be restored. This is very helpful in maintaining Wiki documents, but as our small blog, it does not seem to be of much use. Moreover, this revision occupies an ID in the database, which also causes One of the problems with discontinuous article IDs. To disable article revisions, you can add in the wp-config.php file:

1

define('WP_POST_REVISIONS', false);

2. Delete the article Revisions
After disabling article revisions, the previously created article revisions are still stored in the database. These are actually of little use and occupy the ID. We can delete them. As for how to delete, you can execute the following SQL statement in phpmyadmin (make a backup):

12345

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

3. Delete unnecessary attachments
I believe many bloggers will do this when publishing articles Upload/insert some attachments, such as images, videos, music, etc. These attachments can be seen in the WordPress management background – Media Library. Different media corresponds to different articles. But you should note that these media also occupy the article ID, and they are stored in the same database table wp_posts as the article. If you particularly pursue that the IDs of the articles must be perfectly continuous, please do not upload/insert these media when publishing the article, and please delete the previously uploaded media in the WordPress management background – media library (note that this operation is not just deletion) records, and the files you uploaded will be deleted), please use FTP to re-upload these files if necessary.
4. Disable auto-save
The advantage of auto-save is that when you edit an article, the system will automatically save the edited article for you every short period of time to prevent the webpage from suddenly closing and causing thousands of words to be written before. All of a sudden it was gone. The disadvantage is that each article will have an automatically saved record, which also occupies an article ID, which is one of the reasons why the article IDs are not consecutive. If you do not need this function, please use 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 method no longer supports the latest version of WordPress. After completing the above four steps, it is basically guaranteed that the IDs of the articles published in the future will be continuous. However, the IDs of the articles published before are still in chaos. They must be rearranged to ensure that the IDs are continuous. I wrote a PHP script. You can download it from the following URL. After downloading, open it with a text editor. Modify the database information according to the instructions at the beginning. Then upload the PHP file to your blog space. Run it and see OK. , you can go to phpmyadmin to check whether the IDs in the wp_posts table are consecutive. Again, please back up your database before starting. (If you use post id as a fixed link, it may change the URL of all articles, which will affect search engine inclusion; if you use a plug-in to create a new database table, such as a voting plug-in, etc., problems will also occur; if A page with a parent-child relationship has been created in your blog. If you run the following script, this relationship will be lost. Please use it with caution!)... The rest of the text >>

How to turn off the automatic draft saving function in wordpress?

Just add the following code to wp-config.php:
Copy the code as follows:
define('AUTOSAVE_INTERVAL', 120 ); // Set the auto-save interval in seconds, the default is 60
define('WP_POST_REVISIONS', false ); // Disable article revision function
define('WP_POST_REVISIONS', 3); //

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/904914.htmlTechArticleThe perfect way to implement wordpress's prohibition of article revisions and automatic saving. Wordpress automatically saves using WordPress for so long. I have always hated wordpress. Article revision and auto-save functions also use...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP vs. Flutter: The best choice for mobile development PHP vs. Flutter: The best choice for mobile development May 06, 2024 pm 10:45 PM

PHP and Flutter are popular technologies for mobile development. Flutter excels in cross-platform capabilities, performance and user interface, and is suitable for applications that require high performance, cross-platform and customized UI. PHP is suitable for server-side applications with lower performance and not cross-platform.

How to change page width in wordpress How to change page width in wordpress Apr 16, 2024 am 01:03 AM

You can easily modify your WordPress page width by editing your style.css file: Edit your style.css file and add .site-content { max-width: [your preferred width]; }. Edit [your preferred width] to set the page width. Save changes and clear cache (optional).

How to create a product page in wordpress How to create a product page in wordpress Apr 16, 2024 am 12:39 AM

Create a product page in WordPress: 1. Create the product (name, description, pictures); 2. Customize the page template (add title, description, pictures, buttons); 3. Enter product information (stock, size, weight); 4 . Create variations (different colors, sizes); 5. Set visibility (public or hidden); 6. Enable/disable comments; 7. Preview and publish the page.

In which folder are wordpress articles located? In which folder are wordpress articles located? Apr 16, 2024 am 10:29 AM

WordPress posts are stored in the /wp-content/uploads folder. This folder uses subfolders to categorize different types of uploads, including articles organized by year, month, and article ID. Article files are stored in plain text format (.txt), and the filename usually includes its ID and title.

Where is the wordpress template file? Where is the wordpress template file? Apr 16, 2024 am 11:00 AM

WordPress template files are located in the /wp-content/themes/[theme name]/ directory. They are used to determine the appearance and functionality of the website, including header (header.php), footer (footer.php), main template (index.php), single article (single.php), page (page.php), Archive (archive.php), category (category.php), tag (tag.php), search (search.php) and 404 error page (404.php). By editing and modifying these files, you can customize the appearance of your WordPress website

How to search for authors in WordPress How to search for authors in WordPress Apr 16, 2024 am 01:18 AM

Search for authors in WordPress: 1. Once logged in to your admin panel, navigate to Posts or Pages, enter the author name using the search bar, and select Author in Filters. 2. Other tips: Use wildcards to broaden your search, use operators to combine criteria, or enter author IDs to search for articles.

Which version of wordpress is stable? Which version of wordpress is stable? Apr 16, 2024 am 10:54 AM

The most stable WordPress version is the latest version because it contains the latest security patches, performance enhancements, and introduces new features and improvements. In order to update to the latest version, log into your WordPress dashboard, go to the Updates page and click Update Now.

What language is used to develop WordPress? What language is used to develop WordPress? Apr 16, 2024 am 12:03 AM

WordPress is developed using PHP language as its core programming language for handling database interactions, form processing, dynamic content generation, and user requests. PHP was chosen for reasons including cross-platform compatibility, ease of learning, active community, and rich library and frameworks. Apart from PHP, WordPress also uses languages ​​like HTML, CSS, JavaScript, SQL, etc. to enhance its functionality.

See all articles