PHPology is a collective of highly skilled, award winning, web gurus.
Contact Raj on 07985 467 213 or email [email protected]

Wordpress editor removing iframe tag between visual and html mode

 Supporting a Wordpress website for a client and came across an issue where when they were adding in <iframe> tag into the WYSIWYG and switching from html to visual - visual to html, the code would disappear.

Problem was solved by adding this code to functions.php

function mytheme_tinymce_config( $init )

{

$valid_iframe = 'iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]';

if ( isset( $init['extended_valid_elements'])){

$init['extended_valid_elements'] .= ',' . $valid_iframe;

} else {

$init['extended_valid_elements'] = $valid_iframe;

}

return $init;

}

add_filter('tiny_mce_before_init', 'mytheme_tinymce_config');

Source and much LOVE to: http://www.designzzz.com/how-to-stop-wordpress-editor-from-removing-iframe-and-embed-code/