When switching from html to visual editor the tag gets corrupted

On default is the iframe tag a not allowed tag in the editor. You must change the filter for allowed this html tag. Copy the follow source in a plugin and allow iframe for the editor TinyMCE.

add_filter( 'tiny_mce_before_init', 'fb_change_mce_options' );
function fb_change_mce_options( $tags ) {

    // Comma separated string od extendes tags
    // Command separated string of extended elements
    $ext="iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src|id|class|title|style]";

    if ( isset( $tags['extended_valid_elements'] ) )
        $tags['extended_valid_elements'] .= ',' . $ext;
    else
        $tags['extended_valid_elements'] = $ext;

    return $tags;
}

Leave a Comment