The code you’ve provided does remove the website URL field from the comment form. However, bots can still directly POST to the wp-comments-post.php
file with a URL included. To prevent this, you can remove the URL from the submitted data before it’s saved to the database. You can achieve this using the preprocess_comment
filter.
Add the following code to your theme’s functions.php file:
function xyzmark_remove_comment_author_url( $commentdata ) {
$commentdata['comment_author_url'] = ''; // remove the URL from the submitted data
return $commentdata;
}
add_filter('preprocess_comment', 'xyzmark_remove_comment_author_url');
This code will ensure that even if someone (or a bot) directly submits a comment with a URL, it will be removed before the comment data is saved. Note that this won’t affect the ability of admins to manually add URLs to comments from within the WordPress admin interface.