Subscribe to KS RSS RSS Reader Reader RSS Reader Live

How to Remove All WordPress HTML Comment Tags

Posted by Philip King at 13:03 Add comments

How to Remove All WordPress HTML Comment Tags

HTML Graphic

By default, WordPress allows commentators to use a restricted set of HTML tags in comment, quote and/or format text. In most blogs this "feature" is rarely if ever used but does leave the site open to "spam" links.

In such cases we might be better off removing the HTML tag feature altogether and let commentators use only plain text.

To prevent the use of HTML tags in comments, paste the following code into the functions.php file:

add_filter('comment_text', 'wp_filter_nohtml_kses');

add_filter('comment_text_rss', 'wp_filter_nohtml_kses');

add_filter('comment_excerpt', 'wp_filter_nohtml_kses');

The code applies the WordPress built-in function ‘wp_filter_nohtml_kses‘ to the filters, ‘comment_text’, ‘comment_text_rss’ and ‘comment_excerpt’ used to display comments and strips all HTML tags.

Because this method uses only built-in WordPress core functions, it’s nice and safe and fast!

 

Related Posts

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Copyright © Philip King 2009 King Solutions (UK)
ClickBank - Justhost - Wishlist Member

About - Contact Us
Privacy Policy - House Rules - Site Terms

Suffusion theme by Sayontan Sinha