Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home Tips And Tricks Delete WordPress Revision Posts, Its Relationships And Meta Data

Delete WordPress Revision Posts, Its Relationships And Meta Data

Post Revision Feature in WordPress is very useful in case of a blog with multiple authors/editors. It’s similar to a version control system which tracks the history of changes of your posts/pages on: Who did the change?, When did they change? and What did they change? Therefore, you can review each of saved version and also revert back to a previous version. It means your published contents are always safe and never be overwrite, you can re use them whenever you want.

However, as you know, the revisions are stored in the posts table as children of their associated post and will be auto inserted into the database whenever update your article, even it’s just a minor change. Your database will be grown significantly with lot of revision records creating and definitely reduce the performance, waste resources and increase page loading.

Deleting or removing the Post Revisions is a good idea to increase the web page serving, optimize the performance, reduce the database size, speed up the backup process as well as download/transfer the backup file 🙂

To delete the existing Post Revisions, simple run SQL command below in your PhpMyAdmin or SSH:

[text] delete from wp_posts WHERE post_type = ‘revision’;
[/text]

After that, you may need to delete all its related relationships (in wp_term_relationships table) as well as its meta data (wp_postmeta table):

[text] delete from wp_postmeta where post_id not in (select ID from wp_posts);
delete from wp_term_relationships where object_id not in (select ID from wp_posts);
[/text]

Note:

  • 1. Replace ‘wp_’ with your current table_prefix
  • 2. After delete the Revisions, you can not check the change history or revert your article by an older version so please ensure you understand what you’re deleting. Backup your database and just delete the Revisions in a period of time is a good idea, I think 🙂

Bonus: in order to completely disable the Post Revision Feature, you can add the code below somewhere in your wp-config.php file, it will turn off the feature and will not store any revision post.

[text] define(‘WP_POST_REVISIONS’, false);
[/text]
Jun 28, 2011Hoan Huynh
PHP IP Address To Country City Region Latitude And LongitudeSimple PHP Code Send Email
You Might Also Like:
  • Delete Bulk Draft And Trash WordPress Posts Includes All Tags, Comments, Meta Fields And Terms Associated
  • WordPress Delete Unused Post Tags By SQL Command
  • Get WordPress Most Popular Posts By Total Comments
  • WordPress Get Recent Posts And Recent Comments
  • PHP Delete File Function
  • Auto Delete Old IIS Logs, FTP Logs, SMTP Logs In Windows
  • How To Delete Application In Facebook Developers
  • How To Change Default Home Page Of WordPress
  • Remove/Delete your saved passwords in IE, Firefox, Google Chrome
  • WordPress Check If Post Is In Category
Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at [email protected]

11 years ago Tips And TricksHowto, performance, Wordpress, WP_POST_REVISIONS, wp_postmeta, wp_posts, wp_term_relationships230
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
24,554 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
21,892 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
17,745 views
JQuery Allow only numeric characters or only alphabet characters in textbox
15,069 views
C# Read Json From URL And Parse/Deserialize Json
11,802 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • Things to Learn about Installingderm Loan Type S
  • Online Photo Editor – Free Photoediting Software
  • A Guide to Finding the Best Paper Sellers
  • Photoediting in Home Isn’t Hard to Do!

  • Free Photo Editor Online
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (27)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (141)
  • Uncategorized (647)
Recommended
  • Custom Software Development Company
  • Online Useful Tools
  • Premium Themes
  • VPS
2014 © 4 Rapid Development