WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

Which filter if removed allows iframes to be inserted into wordpress posts?

share|improve this question

marked as duplicate by toscho Nov 21 '13 at 2:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 3 down vote accepted

This filter does not. This feature is disabled in the visual editor TinyMCE.

function wpse49619_change_mce_options($initArray) {
    $ext = 'iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src]';
    if ( isset( $initArray['extended_valid_elements'] ) ) {
        $initArray['extended_valid_elements'] .= ',' . $ext;
    } else {
        $initArray['extended_valid_elements'] = $ext;
    // maybe; set tiny paramter verify_html
    //$initArray['verify_html'] = false;
    return $initArray;
add_filter('tiny_mce_before_init', 'wpse49619_change_mce_options');

Also you can use examples from WPEngineer how to enhancement TinyMCE.

share|improve this answer
Please put relevant code in your answer rather than merely linking to an external site. This one should be straight-forward enough that the code shouldn't be too onerous. :) – Chip Bennett Apr 20 '12 at 1:31
Ok @Chip Bennett, I added little code :) – user15194 Apr 20 '12 at 1:50
Thanks! Now, I can put iframe directly into the editor BUT I used media_send_to_editor($html) to add iframe to editor but 'Add Media' screen hangs up. What could be the problem? – afnrf Apr 21 '12 at 7:22
Ok I found the problem. This happens when Visual (WYSIWYG) is active. Works fine when HTML view is active. – afnrf Apr 21 '12 at 7:54
Well this is because I was getting <iframe ... /> from the Video API I am using. This causes Cannot call method 'indexOf' of undefined in wp-tinymce.php. Should be <iframe ...></iframe>. HTML view auto converts this. WYSIWYG does not! – afnrf Apr 21 '12 at 9:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.