Perhaps many webmasters have experienced being bombarded by spam comments. There are thousands of spam comments in the background. It is very troublesome to delete them manually. The following column will introduce how to delete spam comments in batches. Methods.
Add the following code to the current theme functions.php:global $wpdb; $wpdb->query( " DELETE FROM $wpdb->comments WHERE comment_approved = 'parameter' " );
spam Spam comment
0 Comments to be reviewed
1 Reviewed comments
For example, to delete comments to be reviewed in batches, change the parameter parameter in the code to 0, and delete spam comments to: spam
Tips: Do not change the parameter to 1, otherwise all passed normal comments will disappear and are irreversible, remember!
Please delete the above code after use, there is no need to keep it in the theme.
Or install the delete pending comments plug-in: Delete All Pending Comments
After enabling it, just find the delete operation page in the background comment menu.
The above is the detailed content of Delete WordPress spam comments and pending comments in batches. For more information, please follow other related articles on the PHP Chinese website!