Skip to content

Instantly share code, notes, and snippets.

@MrAlexWeber
Created May 4, 2012 01:46
Show Gist options
  • Save MrAlexWeber/2591192 to your computer and use it in GitHub Desktop.
Save MrAlexWeber/2591192 to your computer and use it in GitHub Desktop.
sql to remove posts from a category given a post author and category id
delete b
from wp_posts a
left join wp_term_relationships b ON ( a.ID = b.object_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 = YOUR_TERM_ID and a.post_author = YOUR_AUTHOR_ID;
@MrAlexWeber
Copy link
Author

please don't blame me if this breaks anything! it worked for me, but you should definitely test it with select * and limit 50 before you run it with delete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment