Skip to content

Instantly share code, notes, and snippets.

@lukecav
Created August 27, 2018 13:54
Show Gist options
  • Save lukecav/5913914384f977829afb21ef2d408b09 to your computer and use it in GitHub Desktop.
Save lukecav/5913914384f977829afb21ef2d408b09 to your computer and use it in GitHub Desktop.
Delete unattached images using WP-CLI
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')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment