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.

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.

Leave a Reply