How to change my 3000 Published post status to Draft using PHPMyAdmin

I have to change my all 3000 published post status to draft. one way to do it one by one or another option is to select bulk post... but bulk selecting also takes a lot of time because I have around 3000+ posts. any easy way to do it? or any plugin? Thank You

Topic bulk phpmyadmin draft posts plugins Wordpress

Category Web


If you have access to phpMyAdmin you can run this SQL query directly:

UPDATE {prefix}posts SET post_status="draft" WHERE post_status="publish"

If you do not have any experience with SQL queries then you should use this solution. Just place this code in functions.php and refresh the WordPress once, and it will be done.

function setPostsToDraft()
{
    global $wpdb;
    $qry = 'UPDATE '.$wpdb->prefix.'posts SET post_status="draft" WHERE post_status="publish"';
    $wpdb->query($qry);
}
setPostsToDraft();

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.