Skip to main content
We are Brand SEO Beijing serving international business, your marketing partner, Contact us by mi@mgsh.com.cn

The website saves the log modification record of the article page

WordPress automatically saves a record of your changes to the log.When you update a post or page, WordPress keeps the post (page) before the update, allowing you to retrieve the pre-update content at any time.These old log stubs will remain in the database forever as historical records, enabling users to see all changes to the log.
But sometimes we also need to do some tidying up of the database.Each revision to the log results in an extra row in the WordPress logs table, and possibly several more entries in the postmeta and term_relationships tables.Deleting some unnecessary records can free up hard disk space while reducing the load on MySQL.

delete previous log records

First remember: Back up your database. The following method will run the SQL statement directly on the MySQL table, a slight deviation will make your WordPress inoperable, so a backup is necessary.
First, find the WordPress table prefix specified in wp-config.php:

$table_prefix = 'wp_';

Wp_ is the default table prefix, but you can change the default to reduce security holes.Here we still use wp_ as the default table prefix.
In order to delete all log and page modifications, first open a MySQL administration tool (such as phpMyAdmin) and run the following statement:

DELETE a,b,c FROM wp_posts a LEFT 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';

(If you changed the table prefix, change "wp_" in the code accordingly.)
If you find this troublesome, you can also choose to delete all log modification records before a certain date. For example, the following statement will delete all log modifications before January 2010, 1:

DELETE a,b,c FROM wp_posts a LEFT 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' AND a.post_date < '2010-01-01';

(Note that MySQL's date format is year-month-day)

Disable or restrict log modification logging

Add the following code to the wp-config.php file of WordPress to permanently disable the function of keeping log modification records:

define('WP_POST_REVISIONS', false);

The value can be set to "true" to reactivate keeping a record of modifications.
Or you can use a positive integer to limit the number of log modification records allowed:

define('WP_POST_REVISIONS', 5);

The above code will keep up to 5 modification records for each log, plus one auto-save record.Modification records five times ago will be automatically deleted

Back to Top