I think, therefore I am. I am, therefore I sail

Add HTML tags to the allowed tags list in WordPress

By default WordPress limits what HTML tags are allowed in post content. If tags that are not whitelisted are found in the content they will be stripped. It is possible add additional tags to the allowed list.

View allowed tags

To view the list of currently allowed tags you can use the following code:

add_action( ‘init’, function() {
echo allowed_tags();

Add to the allowed tags

In this instance I need to allow the iframe tag. Be sure to also specify the allowed attributes:

add_action( ‘init’, function () {
global $allowedtags;

$allowedtags[‘iframe’] = array(
‘src’ => array(),
‘height’ => array(),
‘width’ => array(),

Add allowed tags to the WP Editor

Using the above will allow the iframe tag in code, but what if you want to allow the iframe to be added using the post editor? There is another filter used by tinyMCE which also needs to be set:

add_filter(‘tiny_mce_before_init’, function( $a ) {
$a["extended_valid_elements"] = ‘iframe[src|height|width]’;
return $a


A sailors engagement


Feeling Crafty: First candle project


  1. NIce article i was looking for this !!
    Complete HTML 5 Tags list

  2. Smith

    Really informative article. Thank you!

  3. Buzz

    Useful, it saves my life.

  4. John

    I’ve tried adding this and other methods for allowing HTML to my theme’s functions.php and the kses.php, but when I add a form to a textarea field, WP strips all of the input tags. WHERE should this be put?

    • Hi John! I believe you can put this in the functions.php file in your theme. If that is not working create a plugin or put it in the mu-plugins directory.

Powered by WordPress & Beards