Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@MrAlexWeber MrAlexWeber commented May 4, 2012

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