How to Disable HTML in WordPress CommentsEvery coin has two sides, so does the tags in comments. According to the design, WordPress allows visitors to add HTML tags which can be certain links, style text or tables. By using those tags, the comments can be richer in style and better to convey meanings, which can be very beneficial for visitors.

However, there are often lots of spam containing in those tags, which are used to do adverting and then mislead your visitors. Therefore, to better prevent comment spam, it is quite necessary to disable HTML.

This tutorial is going to introduce two approaches to disable HTML in WordPress comments. First of all, the tutorial will show you how to disable HTML manually, which means by codes. Then, we will display three plugins that can save your troubles.

Why Bloggers Prefer Removing HTML Tags from Comments?

Bloggers are very curious in respect to their blog quality. They intend to use high-quality content for the readers through which they are able to create audience engagement on their page. This in return allows the blog owner to gain a market reputation and valuable search engine page rank. However, there may be an instance that some certain low ranked websites look forward to generating a backlink through an HTML tag of their own website. This is usually done by placing the HTML tag in the comment section.


The impact of this action proves to be beneficial for the person placing the HTML tag because it gives his website a backlink. Contrarily, from the perspective of a blogger, it harms his page because his readers may click on the presented tags and get redirected to some other websites that are of low quality. Therefore, the prevailing state of affairs turns hostile for the blogger and leaves him with no other option than to eliminate the existing HTML tags.

Removing the HTML tags from the blog not only preserves the standard of your blog but also helps you avoid spam comment. The presence of automated bots often acts as a culprit in dissolving the reputation of a blog through random link placement in the comment section. It can be easily avoided if the placements of HTML tags are disabled in the comment section.

Disable HTML Manually

Disabling manually is actually very easy to operate. First of all, you are supposed to log in your dashboard, and go to Appearance and navigate to your theme directory. Next, open functions.php file under your current theme, and add the code below.

function hr360_comment_post( $newComment ) 
	$newComment['comment_content'] = htmlspecialchars($newComment['comment_content']);
	$newComment['comment_content'] = str_replace( "'", ''', $newComment['comment_content'] );
	return $newComment;
function hr360_comment_display( $comment ) 
	return str_replace( ''', "'", $comment );
add_filter( 'preprocess_comment', 'hr360_comment_post', '', 1 );
add_filter( 'comment_text', 'hr360_comment_display', '', 1 );

After those steps, HTML in your comments will be disabled automatically. Then all your comments will include no more tags but to present plain texts.

Disable HTML by Using Plugin

If you find those steps are hard to follow or you are tired of those settings, there are another choice for you: disabling HTML by using a plugin. This tutorial will present two plugins so that you can choose what you prefer.

Peter’s Literal Comments

This plugin is developed by Peter Keung. And now it has updated to version 1.0.2. The plugin is designed only for one purpose – to help users disable the HTML tags in comments. Besides, you need to keep it in mind that the plugin is compatible with at least WordPress 2.5.

Advanced Settings

Except for the first one, there is also another essential plugin named Advanced Settings. Comparing to the plugin above, this plugin is more powerful with many functions apart from disabling HTML, such as post type management, removing the widget system, inserting Google analytics code and so on. Because this plugin is under updating, there are more functions to come.

Besides, all those plugins are available in WordPress plugin directory, so you just need to search the plugins and activate them. Comparing to disabling HTML manually, using a plugin seems to be more convenient because you don’t need to follow any steps or code any codes.


All in all, both methods are easy to operate for beginners. If you have any problems with those steps, just practice several times and then everything will be fine in your comments.