Advertisement
ghiwar

Mysql Delete All Wp Post

May 23rd, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.73 KB | None | 0 0
  1. create temporary table `cull` (`post` int);
  2.  
  3. insert into cull select ID from wp_85affce725_posts where post_status = 'publish';
  4.  
  5. delete from wp_85affce725_posts where ID in ( select post from cull );
  6. delete from wp_85affce725_posts where post_parent in ( select post from cull );
  7. -- done with temp table, cleanup metadata
  8. delete from wp_85affce725_postmeta where post_id not in ( select ID from wp_85affce725_posts );
  9. delete from wp_85affce725_comments where comment_post_id not in ( select ID from wp_85affce725_posts );
  10. delete from wp_85affce725_commentmeta where comment_id not in ( select comment_ID from wp_85affce725_comments );
  11. delete from wp_85affce725_term_relationships where object_id not in ( select ID from wp_85affce725_posts );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement