Skip to content

Instantly share code, notes, and snippets.

@davekuhar
Created December 22, 2023 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davekuhar/d11fbd21b27fe1c48977276b73f9d402 to your computer and use it in GitHub Desktop.
Save davekuhar/d11fbd21b27fe1c48977276b73f9d402 to your computer and use it in GitHub Desktop.
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