Post Pic

How to allow more HTML tags in WordPress comments

By default, WordPress accept a few HTML tags in comments, such as <a>, <strong>, etc… But what if you want to be able to use more HTML tags in WordPress comments? Just read on, I have the solution!

Simply paste the following code in your functions.php file. The list of tags to allow can be modified on line 4.

// Create function which allows more tags within comments
function allow_pres() {
  global $allowedtags;
  $allowedtags['pre'] = array('class'=>array());
}

// Add WordPress hook to use the function
add_action('comment_post', 'allow_pres');

Thanks to David Walsh for the handy tip!

2 Responses

Mar 08 2013 11:41

Any way to remove tags from comments?

Mar 20 2013 06:43

Thanks for the tip. Handy to extend html options in comments. Can you please also advise how to customise (selectively disallow) specific html?

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required

WP Theme of the week

Sponsored Likebox