Comments That Use HTML

Most people who comment on a post or page will type in
one or more paragraphs of ordinary text. However, craftier
commenters may include a few HTML tags to format their
comments.
For example, you can use the <b> and <i> elements to bold and
italicize text. Type this:
I’m <i>really</i> annoyed.
and your comment will look like this:
I’m really annoyed.
You can also add headlines, line breaks, bulleted and numbered
lists, and even tables. You could use the <a> element to create
a link, but that’s not necessary—if you type in text that starts
with www. or http://, WordPress automatically converts it to
a clickable link.
Now that you know you can use HTML in a comment, the
next question is, should you? Most site owners don’t mind
the odd bit of bold or italic formatting, but they may trash
messages that include shamelessly self-promotional links or
ones that attempt to steal focus from the conversation with
wild formatting—it’s like an attention-starved kid throwing a
grocery-store tantrum.
You can edit comments that use HTML inappropriately, but
that takes time and effort. As a safeguard, some site owners
don’t allow HTML elements at all. If you run a self-hosted site,
you can ban HTML by creating a custom theme, an advanced
task detailed in Chapter 13. Once you do, you need to edit
its functions.php file (page 500) and add these instructions
anywhere after the first line (which holds the <?php marker
that starts the code block):
add_filter( ‘comment_text’,
‘wp_filter_nohtml_kses’ );
add_filter( ‘comment_text_rss’,
‘wp_filter_nohtml_kses’ );
add_filter( ‘comment_excerpt’,
‘wp_filter_nohtml_kses’ );
Now WordPress strips out any HTML tags from comments and
disables the linking capability of web addresses.

Advertisements
Comments That Use HTML

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s