How to disable revisions in wordpress. How to disable WordPress revisions. How to Disable Revisions in WordPress

💖 Do you like it? Share the link with your friends

By default, WordPress saves all revisions of posts and articles during intermediate saves during the editing process. Along with revisions, other information can be saved in the database: their metadata and taxonomy. It is unlikely that they can have any negative impact on a small site, but over time the database will grow, and the revisions in it will occupy a much larger volume than the published pages and posts.

Before disabling revisions and deleting old editions, be sure to back up your site files and database.

Disabling or limiting revisions

Saving post and page revisions in the WordPress site database can be disabled or limited in number. To do this you need to open the file wp-config.php and, to disable saving revisions completely, add the line:

Define("WP_POST_REVISIONS", false);

In order to limit the number of saved revisions, replace the word in the added line false by a number corresponding to the desired number of saved revisions. For example, to save 3 revisions, the added line will look like this:

Define("WP_POST_REVISIONS", 3);

Number 0 in this expression will correspond keyword false.

Please note that the added line must be placed in the wp-config.php file after the line:

Define("WP_DEBUG", false);

and before the line:

I added this:

Define("WP_DEBUG", false); /* Cancel or limit the number of revisions */ define("WP_POST_REVISIONS", false); /* That's all, no further editing. Good luck! */

Removing all old revisions

If you did not immediately disable saving revisions, then there might already be quite a lot of them and, if desired, old revisions can be deleted. To do this, you need to log into the phpMyAdmin application, select a database and go to the SQL tab:

Before deleting all revisions from your WordPress site's database, you must first remove their metadata and taxonomy, if any. Copy and paste the following three commands into the input field one by one and click the “Forward” button. If at WordPress installation you specified a prefix other than “wp_” for the database tables, replace “wp_” in the commands below with your prefix.

Removing Meta Data

DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = "revision" AND post_name LIKE "%revision%");

and press the “Forward” button.

Removing a taxonomy

copy and paste the following line into the SQL query input field:

DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type = "revision" AND post_name LIKE "%revision%");

and press the “Forward” button.

Delete all revisions

copy and paste the following line into the SQL query input field:

DELETE FROM wp_posts WHERE post_type = "revision" AND post_name LIKE "%revision%";

and press the “Forward” button.

After executing each command, you will see in the information window how many rows were deleted from the database.

After creating another website on WordPress, I remembered about revisions when I was almost finished working on the first post. When deleting, the following results were obtained:

  • meta data - 0 rows removed;
  • taxonomy - 0 rows removed;
  • revision - 33 lines were deleted.

Editing one post, which was not yet completed, created 33 revisions that I didn't need. No metadata or taxonomy associated with revisions was created.

Want to get rid of unnecessary clutter in your WordPress database? Disable post revisions! If interested, read on.

What are revisions?

When you create new entry or a page on the site, then save it, and after that you edit it several times, the “engine” automatically saves all its versions in its database. They are called revisions.

Why disable revisions in WordPress?

If your site has no more than one dozen entries, then there is nothing to worry about. But if there are more than one hundred of them, it’s worth thinking about. After all, one article can be corrected several dozen times until it is published. This means that several dozen copies of it will be stored in the database. In principle, on the one hand, this is convenient, since it allows you to view all changes, return some of them, etc. But after the publication is posted on the site, no one needs its duplicates.

How to disable revisions in WordPress?

If you are the happy owner of a multifunctional premium plugin, then you will not have to look for any other solutions. One of its functions is to completely disable the creation of revisions. To do this you need to go to the admin section Clearfy Pro and on the tab Additionally activate setting Disable revisions completely.

other methods

Revision Control plugin

Revision Control is a separate plugin for managing revisions on a WordPress website. Its main feature is the ability to specify for which types of posts (Pages or Posts) the creation of copies should be prohibited.

So, after installing and activating it, you should go to the admin panel Settings -> Revisions.

You can disable the creation of revisions for the desired post type. The corresponding fields are used for this: Posts and Pages. To save all changes, click the Save Changes button.

Disable Post Revision plugin

Disable Post Revision is a separate plugin that performs only one function - completely disabling the creation of copies of content. To do this, you just need to install and activate it. The main advantage of the plugin is the absence of any settings pages. It starts doing its job immediately after activation.

Hello dear readers. Today I'd like to talk about revisions in WordPress, how you can limit the number of times they are saved in the database per post or page, and how to disable and delete them completely.

What are editions and why are they needed?

Editorials (revisions) in WordPress- These are backup copies that are saved in the database every time a post or page is updated. On the one hand, this is convenient, since you can always restore backup copy articles for any number, because WordPress saves absolutely all backup copies. But let's imagine that you have a highly loaded project with high daily traffic and a huge amount of content. What then? Then the database may experience enormous loads. What can we do? If you still need revisions of posts and pages, you can limit the number of times they are saved, or you can completely disable and delete them, thereby reducing the load.

Limiting the number of revisions saved

The number of revisions in WordPress can be limited in two ways:

  1. Using the constant WP_POST_REVISIONS;
  2. Using the wp_revisions_to_keep hook (this hook also allows you to select the type of posts for which the restriction is set, be it standard or custom post types).

In order to limit the number of saving revisions using the WP_POST_REVISIONS constant, you need to configuration file wp-config.php (it is in the root of the site) add the following code:

Define("WP_POST_REVISIONS" , 1);

Now, for each post and page, one revision will be stored in the database.

As I wrote above, the wp_revisions_to_keep hook gives more options. Below is an example of code to limit the number of saved revisions with comments, which you need to add to your theme's functions.php file:

/** * Limiting the number of saving revisions using the wp_revisions_to_keep hook * @param integer $count - number of revisions * @param object $post - post object */ function limit_save_revisions_db($count, $post) ( if ($post->post_type = = "page") (//for standard WordPress pages save 1 revision return 1; ) elseif ($post->post_type == "post") (//for standard WordPress Posts save 3 revisions return 3; ) elseif ($post->post_type == "reviews") (//for the custom post type "Reviews" we do not save revisions return 0; ) else (//for all others we save 3 revisions return 3; ) ) add_action("wp_revisions_to_keep ", "limit_save_revisions_db", 10, 2);

Complete disabling and deleting revisions

If you decide to disable revisions on your site altogether, you can also use the wp_revisions_to_keep hook by adding the following code to your theme’s functions.php file:

/* * Total revision deactivations * @param integer $count - number of revisions */ function deactivate_revisions($count) ( return 0; ) add_filter("wp_revisions_to_keep", "deactivate_revisions");

Moreover, after complete shutdown editions, it is advisable to remove them from the database. After all, before the shutdown, they were still preserved and will now lie there as unnecessary “dead” weight. To do this, you need to go to PHPMyAdmin, find the desired database and open the wp_posts table in it. Next, click on the SQL tab and execute the following query:

DELETE FROM `wp_posts` WHERE post_type = "revision";

Now you need to delete all metadata (wp_postmeta table) and taxonomies (wp_term_relationships table) of the editions. To do this, we run 2 more queries:

DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = "revision" AND post_name LIKE "%revision%"); DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type = "revision" AND post_name LIKE "%revision%");

Of course, it's best to back up your database before running these queries.

That's all. I hope the article was useful to you. Good luck to all!!!

Hello everyone, my dear readers of the site. Not long ago we looked at a WordPress theme. But just the other day I had to add one more method to this article. Extremely effective when you have been blogging for a long time, provided that you did not know this trick.

These so-called revisions or, in other words, editions have existed since older versions of cms Wordpress.

Why are post revisions needed?

Revisions of posts and pages are needed only in theory. The point is that they save a backup copy of your article in a database. Moreover, saving occurs every time you change.

It turns out that in the process of writing an article, when you click the “Save” button, a copy of your article is created with your changes. And at any time you can look at the list of these copies and select the most suitable one and restore it.

In all my practice, I have only had to restore a copy from such reserves once. But nonetheless.

On the face of it, the feature seems quite useful. However, you must understand that each such save is an extra load on the database, because all copies are stored there.

Here's an example from life. On average, I had 4-5 revisions of each article on my blog. Imagine when you have hundreds of articles written, and perhaps thousands of articles - by removing revisions (editions) of posts - you will thereby speed up your blog by 5 times.

What if you don’t have 5 revisions, but 10 for each post? By the way, how much do you have, if it’s not a secret? Please write about this in the comments.

By the way, the most interesting thing is that when you don’t even click on the “Save” button, post revisions are created automatically. This is called autosave.

How can I limit the number of post edits?

We already know that all revisions are stored in a database. To change their number, we need a standard “filter”, which is called wp_revisions_to_keep, or using the WP_POST_REVISIONS directive in the wp-config.php file.

By the way, for some reason the directive in the wp-config file did not work for me. Write, for whom does it work in new versions of WordPress?

So, let's say we want to leave the ability to save revisions, but leave, say, only 3 pieces. To do this we need to write the following:

Function my_revisions_to_keep($revisions) ( return 3; ) add_filter("wp_revisions_to_keep", "my_revisions_to_keep");

Using wp_revisions_to_keep you can further limit the number of copies in different types posts More precisely, in one type there is one number of revisions, in another - another.

Well, for example, let’s say you need 5 revisions for pages and 3 revisions for articles (posts) and other types of posts.

Function my_revisions_to_keep($revisions, $post) ( if ("page" == $post->post_type) return 5; else return 3; ) add_filter("wp_revisions_to_keep", "my_revisions_to_keep", 5, 2);

You can also try using WP_POST_REVISIONS in the wp-config.php file, but this method does not allow you to separate post types.

define("WP_POST_REVISIONS", 3);

How to disable and/or delete revisions in wordpress

In the same way, you can refuse revisions altogether. You just need to put the number 0 in the restrictions.

Function my_revisions_to_keep($revisions) ( return 0; ) add_filter("wp_revisions_to_keep", "my_revisions_to_keep");

Or using the wp-config.php file:

Define("WP_POST_REVISIONS", 0);

The most important. Disabling revisions will not affect their existence (already existing ones) in any way. those. if you had 3-5 revisions for each article and you disabled revisions, old copies of posts will still remain. They need to be deleted manually through the database.

How to delete all revisions and editions

So, we disabled the editors. WE already know that simply disabling editors is not enough. You need to uproot them and delete them manually via MySQL.

Let's get started, I guess. But before you delete anything, make a backup. It's better to make a backup of the entire site.

DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = "revision" AND post_name LIKE "%revision%");

We do something similar for taxonomies

DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type = "revision" AND post_name LIKE "%revision%");

And of course, we delete the revisions themselves.

DELETE FROM wp_posts WHERE post_type = "revision" AND post_name LIKE "%revision%";

This MySQL query will delete all revisions in your database. Except for autosaves.

Autosave is also considered a revision, but they are not deleted or disabled!! Therefore, to keep them as small as possible, write the texts in advance in Word, and then simply paste them into the admin area!

A little reminder on how to work with MySQL

In case you forgot.

I work with adminvps hosting, I even told you why in this article. So, I will show everything on it.

Login to phpMyAdmin in your hosting control panel.

Enter your login and password.

We selected the database we needed and clicked the SQL button, which is located at the top.

And we see a large field for writing SQL queries. For the entire Database.

There we enter all requests in order.

Don't worry if you see zero values, it means you simply didn't use left post types or taxonomies.

And this is what I got using the last request.

Look how my blog became faster after this. It's just a fairy tale!

I'm sure you have the same thing! Check it out and write me back about it later.

Plugin for working with post editors

I can also recommend the Revision Control plugin, it allows you to do the same thing as I described, only in a more comfortable mode for you. Right in the admin panel.

If you still have questions, ask, I will be happy to help you. That's all for now. Thank you for your attention.

Majority WordPress users are not even aware of such a thing as “WordPress revisions,” but it is useful to understand what they are, and in some rare cases it is advisable to know how to disable these revisions.

So, revisions (or editions) are copies of your posts that are created every time you save or autosave a page when it changes. This is done in case you want to return to some previous edition of the text or in case of an unexpected computer or communication failure.

I believe that if you do not have any problems in the operation of the site, it does not have a large database that you would like to reduce and there are no comments on the speed of page formation, you should not worry about the presence of editorial staff on the site.

You can see the generated revisions (in Russian WordPress terms) under the editing window.

By switching to any of the text revisions in the list, you will return the text to the state that corresponds to the time when this revision was saved.

As we can see, for each entry there can be many editions, and for a site with a large number of entries they can take up a significant amount of disk space, which can ultimately lead to problems in its operation.

For small sites this is not relevant, but if you have thousands of records and each one is represented in several editions, this can significantly increase the size of the database. Firstly, it slows down work with the database, secondly, these records take up space on the hosting, and thirdly, which, for example, was relevant for me, this may interfere with automatic backup your data. My site data is regularly automatically archived by the plugin and sent to a specific email. If the archive exceeds size limit For Email This technology has stopped working.

Setting up revisions

How to remove Wordpress editorial staff? First, you can specify the following instructions in the wp-config.php file (located in the root folder of your site):

define("WP_POST_REVISIONS", 0);

which means keeping only the three most recent revisions.

You can delete revisions that have already accumulated in the database in at least two ways.

1. Delete directly in the database

We go to phpMyAdmin and then go to the desired database. Then in the top menu go to the “SQL” tab. A window will appear in which you need to enter the SQL command:

And click the button below - “OK” (or “Forward”). That's it, the editions have been deleted.



tell friends