Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1209802
    jmacreations
    Participant

    I am designing a custom page template using ACF and hoping to be able to embed a youtube video with the [x_video_embed] shortcode. Using an ACF field for the URL part of the shortcode. I currently have this:

    
    <?php 	if( get_field('video_link')) {
    		$videoURL = get_field( "video_link" );
    		$videoShortcode = '[x_video_embed]<iframe width="1280" height="720" src="'.$videoURL.'" frameborder="0" allowfullscreen></iframe>[/x_video_embed]';
    		echo do_shortcode( $videoShortcode );
    	}?>
    

    The code works fine if i don’t use the variable. It’s only when i use the variable does it not work. When I echo the value of the variable to the page, it is exactly what i want in the src=”” section.

    I have tried many solutions and wondering why this is not working. Any help would be greatly appreciated. Even a completely different way of embedding a video from a YouTube URL.

    #1209830
    jmacreations
    Participant

    SOLVED!
    replace the $videoShortcode line with:
    $videoShortcode = '[video width="1280" height="720" src="'.$videoURL.'"]';

    For some reason the [x_video_embed] shortcode does not work well. Maybe because it has opening and closing parts?

    I hope this helps someone in the future – maybe devs have a different solution that uses the x shortcode?

    #1209919
    Christian
    Moderator

    Glad you’ve sorted it out and thanks for sharing. 🙂

  • <script> jQuery(function($){ $("#no-reply-1209802 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>