allowedtags for commenters in WordPress

The Problem

It seemed like I couldn’t get a good answer for this pretty simple problem. Most people want to delete that little text at the bottom of the comments section that tells you what HTML tags you can use. That doesn’t make much sense to me. I just wanted to add to it, so people could post code if they wanted to.

The Solution

Open functions.php, type:

// allow more tags within comments
$allowedtags['pre'] = array();

And now we can use the <pre> tag in the comments and the message reflects that.

If you want to preserve the alphabetical order of the keys in their listing, try:


More Reading on kses and allowedtags

If you’re interested in kses, check out this. kses is what parses the HTML from the comments to make sure nothing crazy is put on the page.

There seems to be some confusion over whether allowedtags or allowedposttags is preferable. allowedtags is the more restrictive of the two, and seems to be used for anonymous users. I can’t seem to find any good documentation on what the precise difference is, so maybe someone can point me in the right direction.