I'm using WP YouTube Lyte to show YouTube videos. I'm combining it with Advanced Custom Fields so that the user can just add the YouTube id to show the video. I'm using the WP YouTube Lyte short code but it is writing the code the wrong way round.

Below is the code:

<?php if( get_field('video_file') ): 
$video = the_field("video_file");
<?php echo do_shortcode('[lyte id="'. $video . '" /]'); ?>
<?php endif; ?>

Here is the result:


When I just add a YouTube id into the code it displays the video correctly.


the_field() prints the value, it doesn’t return the string, so you cannot use it in a variable. Use …

$video = get_field("video_file");

… instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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