Created
December 22, 2023 00:28
-
-
Save davekuhar/d11fbd21b27fe1c48977276b73f9d402 to your computer and use it in GitHub Desktop.
Via an answer found at https://wordpress.stackexchange.com/questions/262823/how-can-i-batch-delete-all-unattached-images-with-wp-cli-or-other-automated-proc
It works.
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 db query --skip-column-names --batch "select DISTINCT p1.ID from wp_posts p1 | |
left join wp_posts p2 ON p1.post_parent = p2.ID | |
where p1.post_type = 'attachment' | |
AND p2.ID is NULL") --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment