Delete post revisions in WordPress with wp-cli
Easily remove revisions using wp-cli. First, get a list of revisions with:
$ wp post list --post_type='revision' --format=ids
This command will provide a list of revisions by post ID.
To remove those revisions, use to following command:
$ wp post delete $(wp post list --post_type='revision' --format=ids) --force
This command will provide feedback to stdout as Success: Deleted post XXX.
Where XXX is the post ID of the deleted post. The --force
flag may not be necessary, but was in my case since the command failed with the warning: Warning: Posts of type 'revision' do not support being sent to trash.