Skip to content

Instantly share code, notes, and snippets.

@sabrina-zeidan
Created July 22, 2017 14:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sabrina-zeidan/5d8220f1d4c82eef9b233576deb74739 to your computer and use it in GitHub Desktop.
Save sabrina-zeidan/5d8220f1d4c82eef9b233576deb74739 to your computer and use it in GitHub Desktop.
Delete all spam comments [Wordpress]
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