Spammers are evil, really evil. I love to send all the spam comments on their real place, which is the trash/spam tab of my WordPress. If you found out that a user(s) with more than a few comments had set a spam link as its author URL, then you can bulk delete author URLs from comments.
[alert style=”red”]Note: Please remove this code immediately after saving your functions.php file. You only need to run this code once, there’s no need to keep this code in your theme.[/alert]
Delete All Comment URLs
To completely remove author URLs from comments, just run the following code in your current theme’s functions.php file:
global $wpdb; $wpdb->query( " UPDATE wp_comments SET comment_author_url = ''; " );
To Delete All Comment URLs Except A Specific URL
To delete all URLs but a specific one from comments, just run the following code in your current theme’s functions.php file:
global $wpdb; $wpdb->query( " UPDATE wp_comments SET comment_author_url = '' WHERE NOT comment_author_url = 'https://www.trickspanda.com/'; " );
To Delete All Comments With A Specific URL
To delete all URLs with a specific one from comments, just run the following code in your current theme’s functions.php file:
global $wpdb; $wpdb->query( " UPDATE wp_comments SET comment_author_url = '' WHERE comment_author_url LIKE 'http://www.spam.com' ; " );