11

I'm trying to mass delete 4000 images in a wordpress website. WP itself sets the max to 999, which would work fine and take a few minutes to delete them via the backend. However, I get REQUEST URI TOO LARGE because the backend form uses GET instead of POST.

How can I use WP-CLI to perform the operation if it's possible and ensure the integrity of the WP database. In other words, I don't want to run an SQL command.

0

1 Answer 1

27

From the WP-CLI documentation about wp post delete:

wp post delete --force $(wp post list --post_type='attachment' --format=ids)

See wp post list for additional information.

2
  • 1
    I get this: Warning: Posts of type 'attachment' do not support being sent to trash. Please use the --force flag to skip trash and delete them permanently.
    – Flimm
    Oct 3, 2019 at 16:27
  • @Flimm it is becaus your probably miss the "--force" arg. It works as a charm otehrwise ;) Feb 3, 2020 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.