WordPress comments can be a double-edged sword. Throw in trackbacks / pingbacks and you may find yourself in an unfriendly situation. Comment spam is notoriously exploited on WordPress platforms… largely due to naivety of website owners who have no idea what these terms mean or how to manage them effectively.
If you’re coming in on the tail-end of mitigating comment spam on a blog that has hundreds, even thousands of posts… disabling comments can be a bear. The WordPress administrative interface can be fickle about bulk editing more than 50 – 100 posts at once.
Below I’m going to show you how to quickly and swiftly disable the comments and pings for all posts in WordPress, through your MySQL database. I’m assuming you are already familiar with gaining access to the database of your WordPress website. And if you’re going to copy/paste/execute the code below without taking precautionary measures, please don’t get mad if things go awry.
- Launch PhpMyAdmin
- Select the WordPress database associated with your website
- Select the wp_posts table in the sidebar
- Once loaded, select the “SQL” tab in the main area
- Copy & paste the SQL code provided below into the SQL Run box
- Execute the code
UPDATE `wpblog_posts` SET `comment_status`='closed',`ping_status`='closed' WHERE `comment_status` = 'open';
If you were smart enough to change the default table prefix on your WordPress tables during installation, you’re going to have to change the reference to ‘wpblog_posts’ to reflect your table structure correctly. That’s all you need to do to close commenting and pingbacks on WordPress posts.
Back-peddling on Comment Spam
If you aren’t concerned with culling through thousands of lines of spam in an attempt to find legitimate comments, you can delete all comments very easily from your WordPress website.
- In the same PHPMyAdmin session, locate and select the wp_comments table from the sidebar
- Click on the “Operations” tab in the main area
- Click on “Empty the table (Truncate)” hyperlink
This will delete all contents of the wp_comments table, while keeping the structure intact.