Created
August 27, 2018 13:54
-
-
Save lukecav/5913914384f977829afb21ef2d408b09 to your computer and use it in GitHub Desktop.
Delete unattached images using WP-CLI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wp post delete $(wp post list --post_type='attachment' --format=ids --post_parent=0) | |
wp post delete $(wp post list --post_type='attachment' \ | |
--format=ids --post_parent=0 --post_mime_type='image/jpeg') | |
wp post delete $(wp post list --post_type='attachment' \ | |
--format=ids --post_parent=0 --post_mime_type='image/png') |
the command returns Argument Too Long.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://wordpress.stackexchange.com/questions/262823/how-can-i-batch-delete-all-unattached-images-with-wp-cli-or-other-automated-proc
https://developer.wordpress.org/cli/commands/post/delete/