How can I bulk delete media and attachments using WP-CLI?

admin2025-04-19  0

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.

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.

Share Improve this question asked Mar 31, 2015 at 14:04 user658182user658182 6252 gold badges14 silver badges35 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 31

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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745021878a280428.html

最新回复(0)