How To Disable HTML In WordPress Comments
How to Disable HTML in WordPress Comments

We all despise spam comments and comments that are only written to promote links. A huge number of HTML tags may be seen in many of the spam comments. Fortunately, the built-in Akismet plugin simply filters out spam comments from valid ones. It does not, however, ban the usage of HTML code in the comments area. It’s a good idea to block HTML publishing in your WordPress comments. This guide will teach you how to deactivate HTML tags in WordPress comments.

This guide will only deactivate active HTML tags. It will not restrict the use of escape tags in HTML, such as:

If the HTML tags are posted in this manner, they will appear but will not operate. For example, if someone publishes the anchor tag, it will no longer be functioning.

Why Should WordPress Comments Be Disabled?

Comments allow you to engage with your audience while also improving your SEO. However, in rare circumstances, comments might be detrimental to your website.

You can watch the video tutorial below for this article:

Consider a tiny company website with a few pages (about us, contact us and introduction). To make the website appear more inviting, a tiny website must obviously deactivate its comment area.

Then again, large business sites will most likely be unable to control the approaching remarks and the quantity of remarks might actually diminish the site’s presentation and make issues for the information base. For this situation, you really want to incapacitate your remark area too.

How Can I Stop Spam Comments?

Spam comments are a website owner’s worst fear. Because it clogs your database and causes a flood of bogus comments to be published on your website, which harms your SEO and database. But how can you stop spam comments? This topic was covered in another article. However, we will attempt to provide a few tips here. 

You may, for example, block WordPress comments so that no one can submit any comments.

This strategy is beneficial for websites that do not require a comment area. But what about those types of sites that rely quite heavily on the comments? 

Another method for dealing with spam comments is to restrict access to the comment area. Dealing with spam comments may be accomplished by manually vetting comments, blocking links, employing a blacklist or review list, and enabling only your users to make comments. 

Finally, there is another approach to prevent spammer bots from leaving comments on your website. To prevent bots from leaving comments on your website, utilise Google reCAPTCHA technology. Merely download and just simply install the noCAPTCHA or Advanced Invisible CAPTCHA plugin.

Once you’ve received your API keys, you may activate them and utilise this technology to prevent spam comments on your website.

So, how do you turn off HTML in WordPress comments?

  • Firstly, open your WordPress Admin dashboard.
  • Hover on to Appearance.
  • After that, just simply go and tap on Theme Editor.
  • Go ahead and just tap on Theme Functions from the right hand side of the screen.
  • Scroll downwards until you finally reach the end of the screen.
  • Here you have to enter a small piece of code.
Disable HTML in WordPress Comments

NOTE: Before making any code-related changes, it is suggested to have a backup of your website JUST IN CASE anything goes wrong, then you can at least restore it afterwards.

Code:

// This will occur when the comment is posted

    function plc_comment_post( $incoming_comment ) {

    // convert everything in a comment to display literally

    $incoming_comment[‘comment_content’] = htmlspecialchars($incoming_comment[‘comment_content’]);

    // the one exception is single quotes, which cannot be #039; because WordPress marks it as spam

    $incoming_comment[‘comment_content’] = str_replace( “‘”, ‘'’, $incoming_comment[‘comment_content’] );

    return( $incoming_comment );

    }

    // This will occur before a comment is displayed

    function plc_comment_display( $comment_to_display ) {

    // Put the single quotes back in

    $comment_to_display = str_replace( ‘'’, “‘”, $comment_to_display );

    return $comment_to_display;

}
Disable HTML in WordPress Comments
  • Copy and paste the code in the end.
  • Simply click on the Update File.
  • Once the file is updated successfully, you can go to the website and check if the HTML in WordPress comments has been disabled.

As long as you carefully followed every single step that we mentioned above, you must have successfully disabled the HTML in WordPress Comments. In case you have more queries, and require more help, feel absolutely free to check out our website or contact Digital Suncity. 

Also Read: How to Set Minimum Word Count For WordPress Posts

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Need Professional Help?

We can help you with website fixes and ongoing maintenance.