Allow More HTML Tags in WordPress Comments

WordPress allows few HTML tags within the content of post comments. This is a good feature because it prevents security holes and other malicious code from being injected by spammers or hackers.

There are many other tags that bloggers may want to support, design and development bloggers may want to support PRE tags so commenters can post code.

Add the following code in your functions.php file.

/** Function Allows More Tags Within Comments */
function allow_pres() {
global $allowedtags;
$allowedtags['pre'] = array('class'=>array());
/** WordPress Hook To Use The Function */
add_action('comment_post', 'allow_pres');

The global $allowedtags variable holds an array of allowed comment tags, so adding the ‘pre’ key will allow PRE elements within comments.

I hope you like this post, Please feel free to comment below, suggestion and problems!

(Visited 8 times, 1 visits today)
Chandra Kumar

Hello World, I am Chandra Kumar from New Delhi, India. I am professionally developer, programmer and blogger. I am the founder of

0 Comment

Leave a Comment

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