In WordPress, allowed_tags() returns a text string that lists the HTML tags (and attributes) commenters are allowed to use, such as <a href="" title=""> and <strong>.
The string is already HTML-encoded, so when you echo it the visitor sees the tag names as plain text. It is handy for a small hint under a comment form.
Syntax
It takes no arguments. Echo the result where you want the hint to appear.
WordPress
<?php
echo allowed_tags();
?>
Call
What it does
allowed_tags()
Returns the allowed tags as an encoded string.
echo allowed_tags();
Prints the list so visitors can read it.
$allowedtags
The global array that WordPress reads to build the string.
The function only returns the string. It does not print by itself.
Full declaration
WordPress
allowed_tags(): string
Parameters
Parameter
Description
None
This function takes no parameters.
Return Value
Return Value
Description
string
The allowed tags and attributes, written as HTML entities, for example <a href="">.
WordPress Examples
Three short theme examples. Each one shows the code and what it prints.
Example 1 — Show a hint under the form
Tell commenters which tags they may use.
WordPress
<p class="comment-hint">
You may use these HTML tags:
<code><?php echo allowed_tags(); ?></code>
</p>
Output
You may use these HTML tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
How It Works
allowed_tags() builds the list.
echo prints it inside the <code> tag.
The browser shows the tag names as text, not as real HTML.
Example 2 — Add the list to the comment form
Use the comment form filter to add a note after the form.