Allow More HTML Tags in WP 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.

[php]
/** 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’);
[/php]

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

You may also be interested in our other articles on disable auto generated paragraph tagsnofollow wordpress tag cloudimprove wordpress jpeg image quality and force auto update of wordpress.


Comments

Leave a Reply

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