Change status of all Wordpress posts with MySQL
- September 2nd, 2009
- Posted in Tutorials
- Write comment or click if you like the post:
Sometimes you just want to archive everything. It’s really easy with a few simple SQL statements. I just used phpMyAdmin but you can do it directly if you want.
Examples:
Change published posts to drafts
UPDATE `wp_posts` SET `post_status` = 'draft' WHERE `post_status` = 'publish'
Inherit
UPDATE `wp_posts` SET `post_status` = 'draft' WHERE `post_status` = 'inherit'
Future(scheduled)
UPDATE `wp_posts` SET `post_status` = 'draft' WHERE `post_status` = 'future'
UPDATE
After setting every post to draft you may want to republish posts containing a certain term:
UPDATE `wp_posts` SET `post_status` = 'publish' WHERE `post_content` LIKE '%searchterm%'
No comments yet.