Learn How To Add Iframe In WordPress Post

By default wordpress does not allow you to add iframe code into the blog post due to security reasons but if you need to add it, you can do it in following two ways:

1. Add the following code to the functions.php file

function add_iframe($initArray) {
$initArray['extended_valid_elements'] = “iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]“;
return $initArray;
}
add_filter(‘tiny_mce_before_init’, ‘add_iframe’);



2. you can install Iframe plugin and then to embed the iframe into post, you just need use shortcode as follows:

[iframe width="640" height="480" src="http://example.com/video/3261363"]

click here to download Iframe plugin

Get Updates

Related Posts

  • paburmester

    This code give me an error on this line: add_filter(‘tiny_mce_before_init’, ‘add_iframe’);

    • raj

      i used this code and it is working fine for me, you can check in your code whether you have placed it right or not.

    • John

      just for the sake of others, be sure the single and double quotes you copy/paste don’t become “special characters.” That happened to me and I caught it. They will look Italic.

© 2013 mlivetech. All rights reserved.