Home > CMS Tutorial > WordPress > body text

Delete WordPress spam comments and pending comments in batches

藏色散人
Release: 2019-11-04 11:42:15
forward
2949 people have browsed it

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'
" );
Copy after login
Delete WordPress spam comments and pending comments in batchesOptional parameters:

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!

Related labels:
source:zmingcx.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template