According to this: https://codex.wordpress.org/Embeds

You can just paste in your YouTube link into your post body and it becomes an embedded YouTube Video. This works for me, but it seems to ignore any parameters I pass the YouTube link. For example, if I paste in:


The generated HTML is:

<iframe width="500" height="281" src="https://www.youtube.com/embed/XYZ12345?feature=oembed" frameborder="0" allowfullscreen=""></iframe>

As you can see, the &rel=0 parameter is missing from the generated embed html. Is there a trick to passing parameters to the embed?

1 Answer 1


There's always a filter you can use to hook into the output, see embed_oembed_html. Try this in a custom plugin or child theme's functions file, it will add any other query strings to the iframe src attribute:

add_filter("embed_oembed_html", function( $html, $url, $attr ) { 
    parse_str(parse_url($url, PHP_URL_QUERY), $url);
    if ( $url ) {
        foreach ( $url as $q=>$v ) {
            preg_match('/src="([^"]+)"/', $html, $src);
            if ( isset( $src[1] ) ) {
                $html = str_replace(
                    add_query_arg( array( $q=>$v ), $src[1] ),
    return $html;
}, 10, 3);

Make sure there are no query strings you don't want to add to the iframe src and skip them with a continue; in the loop.

Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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