Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

vTyDi22_SFohttpv://www.youtube.com/watch?v=

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

share|improve this question

1 Answer 1

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.

share|improve this answer
    
Thanks. So simple!!! –  Josh Dec 27 '12 at 11:07

Your Answer

 
discard

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.