Skip to content

Instantly share code, notes, and snippets.

@Irfan-Ansari
Created July 15, 2015 13:45
Show Gist options
  • Save Irfan-Ansari/00f7b8d12ddfddc16f4d to your computer and use it in GitHub Desktop.
Save Irfan-Ansari/00f7b8d12ddfddc16f4d to your computer and use it in GitHub Desktop.
Delete posts from selected category within the date range.
delete a, b, c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN wp_postmeta c ON ( a.ID = c.post_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 e.term_id IN (10)
AND a.post_type = 'post'
AND a.post_date BETWEEN '2008-01-01' AND '2013-01-15';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment