Created
July 22, 2017 14:00
-
-
Save sabrina-zeidan/5d8220f1d4c82eef9b233576deb74739 to your computer and use it in GitHub Desktop.
Delete all spam comments [Wordpress]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bulk_delete_spam_comments(){ | |
$args = array('fields' => 'ids','number' => '','status' => 'spam'); | |
$comments = get_comments( $args ); | |
foreach ($comments as $comment) { | |
wp_delete_comment( $comment, true); | |
} | |
} | |
add_action( 'wp_head', 'bulk_delete_spam_comments' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment