How to add a YouTube video into WordPress 3

Since WordPress and YouTube changed the possibility to embed videos it is not as easy as before. YouTube has an new iframe integration code:

<iframe width="560" height="315" src="" frameborder="0" allowfullscreen></iframe>

but WordPress prohibits the inclusion of iframes in the standard configuration.

I found an easy way to change this.

  1. You have to change your function.php, so go to “Appearance” -> “Editor” and open the function.php in the integrated wordpress editor. But be careful and if you’re don’t know what you are doing, I advise you to make a backup or ask someone.
  2. Look in the code if there is already a row in which the filter “add_filter(‘tiny_mce_before_init’, …); is applied. If not, add the following code:
    /*Add iframe to TinyMCE*/
    function fb_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;
    return $initArray;
    add_filter('tiny_mce_before_init', 'fb_change_mce_options');
  3. That’s it. Now you can use the new Youtube integration code by posting it into an articles html.


Tagged with: , , ,
Posted in wordpress
1 Comment » for How to add a YouTube video into WordPress 3
  1. Bernhard vom TV Ebern says:

    Danke! Genau das habe ich gesucht. Die Einbindung von einzelnen Videos war easy. Aber mit Playlists habe ich mir (fast) die Zähne ausgebissen. :-)

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

More aboute me
Give me a +

donate my work ♥ → paypal