What Are Post Revisions in WordPress?
WordPress post revisions are a built-in feature that automatically saves previous versions of posts and pages during editing. These revisions help users track changes, compare different versions, and restore older drafts if needed.
How Post Revisions Work
Each time a post or page is updated, WordPress stores a new revision in the database. Users can access these revisions through the editor’s “Revisions” option. Every revision includes a timestamp, the author’s name, and a record of changes compared to the previous version.
Types of Post Revisions
- Auto-saves: WordPress generates an automatic revision every 60 seconds while editing a post. This prevents data loss in case of a browser or system crash. Only the latest auto-save is retained.
- Manual revisions: A new revision is saved each time the update or publish button is clicked. These revisions remain in the database unless manually deleted or limited.
Accessing and Restoring Post Revisions
Post revisions can be found within the post editor. The “Revisions” option appears in the right-hand settings panel after at least one update has been made. Clicking it opens the revision comparison screen.
- The latest revision appears on the right, while the previous one appears on the left.
- Changes are highlighted in green (added content) and red (removed content).
- A slider at the top allows users to browse different revisions.
- Clicking “Restore This Revision” replaces the current content with the selected revision. This option is unavailable if the current version is selected.
Managing Post Revisions
Excessive post revisions can increase database size, which may affect performance. WordPress allows users to limit or disable revisions through code or plugins.
Limiting Post Revisions
To control the number of revisions WordPress retains, define a revision limit in the wp-config.php file:
php
define('WP_POST_REVISIONS', 5);
This setting limits each post to five stored revisions. Setting it to false disables revisions entirely.
Deleting Old Revisions
Unnecessary revisions can be removed using SQL queries or plugins. For database cleanup, run the following query in phpMyAdmin:
sql
DELETE FROM wp_posts WHERE post_type = 'revision';
Plugins like WP-Optimize and WP-Sweep provide automated options for managing and cleaning revisions.
Benefits of Post Revisions
- Error recovery: Writers can restore content if unwanted changes are made.
- Multi-author tracking: Editors can review and manage contributions from different users.
- Content comparison: Users can view modifications over time.
Common Issues and Troubleshooting
- Revisions not appearing: If the “Revisions” option is missing, check if it is enabled in “Screen Options” or confirm that revisions are not disabled in wp-config.php.
- Database bloat: Large numbers of revisions can slow down queries. Cleanup tools can help reduce database size.
- Plugin conflicts: Some plugins may restrict revisions. Deactivating them temporarily can help identify the issue.
Database Storage
WordPress stores revisions in the wp_posts table with a post_type value of revision. Each revision consumes database space, making it important to manage them effectively, especially on sites with frequent updates.