↑ ↓ select, Enter open, Esc close

Delete all post revisions

Adjust the values, the command updates live
user@server
wp post list --post_type=revision --format=ids --path=/var/www/vhosts/example.com/httpdocs | xargs -r wp post delete --force --path=/var/www/vhosts/example.com/httpdocs

Finds all revisions and deletes them permanently. Older versions of posts can no longer be restored afterwards. This can shrink wp_posts and wp_postmeta considerably, and running wp db optimize afterwards is worthwhile.

Note: Limit future revisions with define('WP_POST_REVISIONS', 5); in wp-config.php. Create a database backup first.

Also searched as

  • remove wordpress revisions
  • wp_posts table too large
  • delete old post versions

Related one-liners

All in WP-CLI

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.