Recently, I wrote about how WordPress users can easily add media like YouTube videos to posts and pages by just inserting the URL of the page the media is on. But that functionality was limited to sites that are oEmbed providers. We are still left with the problem of not being able to insert non-oEmbed iframes in WordPress, like Google Forms for example. If you try to insert a Google Form in the WordPress editor, you may find that all of the HTML is stripped out and you’re just left with a lonely “Loading…” on your page.

Well, there’s a solution. There’s an awesome thread on WordPress StackExchange with a collection of code for the functions.php file, including the following:

// make TinyMCE allow iframes
add_filter('tiny_mce_before_init', create_function( '$a',
'$a["extended_valid_elements"] = "iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]"; return $a;') );

Copy and paste the code into your WordPress functions.php file, and now you can embed any ol’ iframe you want in your WordPress editor, and it won’t get stripped out!

Happy embedding!