Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Delete unwanted posts and their meta
DELETE a,b,c,d
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN wp_postmeta c ON ( c.post_id = a.ID )
LEFT JOIN wp_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )
LEFT JOIN wp_terms e ON ( e.term_id = d.term_id )
WHERE a.post_type = 'post' AND a.post_date > timestampadd(day, -1, now())
DELETE FROM wp_posts WHERE post_type = 'attachment' AND post_date > timestampadd(day, -1, now())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment