Wordpress is a popular CMS (Content Management System) software that is being used by millions of Websites. Wordpress Comment Spam is very annoying for maintainers in the form of moderation. Though there are readymade Plugins like Akismet, those are paid plugins to get full functionality. People type the website name in the comment form thinking that they will get a backlink from your site. Let us know how to remove a Website or URL field from Comment Form using PHP code.
Many SEO (Search Engine Optimization) techniques stress the importance of having a diversified link profile spread across many websites. So spammers spam the Comment Form with the Website of their choice. If you remove the Website field from the Comment Form, spammers do not leave a comment. Hence you can stop or block comment spam to some extent.
Remove Website or URL Field from Comment Form of Wordpress
The best way of removing a Website or URL field from the Comment Form of Wordpress is by writing a Custom Function in PHP. This custom function alters the functionality of existing Comment Form by removing or allowing the individual fields of the form. In other words, we try to hide the desired field of the Comment Form. We do not recommend any Plugins because loopholes in old plugins lead to website hack.
Step 1: Login to the Wordpress Site using an Admin Username and Password.
Step 2: Go to the option Appearance. Now open the Theme Editor.
Step 3: Make sure, you have selected a working Theme.
Step 4: Open functions.php file by clicking. At the end of the functions.php file contents, add the below PHP code. Save or Update the file.
add_filter('comment_form_default_fields', 'website_field_remove'); function website_field_remove($fields) { if(isset($fields['url'])) { unset($fields['url']); } return $fields; }
Step 5: Clear any Cache. Now Your comment form does not show the "Website" field or URL.
This is how we prevent comment spam in Wordpress by removing the Website field from the Comment Form using PHP code.
Try learning how to submit your Yoast Sitemap in Wordpress to Google Search Console without any Pending Error here.
You can go through this HTACESS redirect guide useful for your Wordpress SEO benefit.
Share this article with your friends and colleagues to encourage authors.