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

How can i add :

class="youtube-player" type="text/html"

to iframe like :

 function Oembed_youtube_no_title($html,$url,$args){
    $url_string = parse_url($url, PHP_URL_QUERY);
    parse_str($url_string, $id);
    if (isset($id['v'])) {
        return '<iframe class="youtube-player" type="text/html" src="https://www.youtube.com/embed/' .$id['v'].'?vq=large&autohide=1&autoplay=1&fs=1&hl=fr&rel=0&loop=1" frameborder="0" allowfullscreen></iframe>';
    return $html;
share|improve this question

You can try this:

add_filter( 'embed_oembed_html', 'custom_youtube_oembed' );
function custom_youtube_oembed( $code ){
    if( stripos( $code, 'youtube.com' ) !== FALSE && stripos( $code, 'iframe' ) !== FALSE )
        $code = str_replace( '<iframe', '<iframe class="youtube-player" type="text/html" ', $code );

    return $code;

to target the YouTube oembed HTML output.

When I embed this YouTube link (Kraftwerk) into the post content


I get this HTML output:

<iframe class="youtube-player" type="text/html"  
        width="625" height="469" 
        frameborder="0" allowfullscreen></iframe>

with the above filter.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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