I have a custom field where I define the Youtube Url as a string.


This then becomes the src in my theme's shortcode:

    $ysrc = get_field('fl_tube');
    if($ysrc) :
        $poster = wp_get_attachment_image_src( get_post_thumbnail_id( $entry_id ), 'entry-fullwidth', false ); 
        echo do_shortcode( '[x_video_player src="' . $ysrc . '" poster="' . $poster[0] . '" preload="metadata" hide_controls="false" autoplay="false" loop="false" muted="false" no_container="true"]' ); 

Wordpress renders this code and produces:

<div class="mejs-mediaelement">
    <iframe class="me-plugin" id="me_youtube_0_container" frameborder="0" allowfullscreen="1" title="YouTube video player" width="480" height="270" src="https://www.youtube.com/embed/3VqHtEF3LPE?controls=0&amp;wmode=transparent&amp;enablejsapi=1&amp;origin=https%3A%2F%2Fwww.mydomain.com&amp;widgetid=1">

In order to hide relative videos and info, I need to append to the url in iframe src:


I cannot add this in my custom field string because then the iframe src output displays erroneously as:


Is there a workaround using javascript or a function maybe to append &amp;rel=0&amp;showinfo=0 to the iframe src for all youtube videos embedded on my site.

1 Answer 1


Try to wordpress function embed

        global $wp_embed;
        echo $wp_embed->run_shortcode('[embed width="123" height="456"]http://www.youtube.com/watch?v=dQw4w9WgXcQ[/embed]'); 
  • This embeds YouTube's embed object, not mediaelement video player.
    – brownian
    Dec 9, 2017 at 14:04

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.