In this tutorial we will show you how you can disable HTML tags in your WordPress comments.
By default, WordPress allows certain HTML tags within the comments such as <a> <em> <strong> etc. If you notice a lot of SPAM comments also contain these tags. Most SPAM comments are made by bots and scripts, which are using HTML tags. If you simply disable HTML from your WordPress comments, it can prevent a lot of SPAM.
Only active HTML tags will be disabled in this tutorial.For example, someone could still post something like:
As a result, It will appear, but the tags will be ineffective. As a result, if the strong tag is used, the text will not be bolded. Furthermore, few SPAM bots have the time to accomplish this because it takes a long time and is not lucrative to them.
To do so, simply open your functions.php file and add the following code:
If you don’t want to manually apply this code, the original author also has a plugin available for download. Peter’s Literal Comments is a simple plugin to install and activate.
This method is superior because it does not necessitate changing the core files. If you wish to make changes to your core files, go to wp-includes/kses.php and make changes there.(This is not recommended, but it is included for educational purposes.) (For further information, see the WordPress Codex.)