Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Created February 12, 2014 16:47
Show Gist options
  • Save wpsmith/8959454 to your computer and use it in GitHub Desktop.
Save wpsmith/8959454 to your computer and use it in GitHub Desktop.
SQL: Delete all posts of a custom post type with its associated meta data (taxonomies, post meta)
DELETE a,b,c
FROM {PREFIX}_posts a
LEFT JOIN {PREFIX}_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN {PREFIX}_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'POST_TYPE' AND a.post_date < '2014-01-01'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment