alanzap Posted August 18, 2015 Share Posted August 18, 2015 Hi All, I think it's a synthax issue I have, I'm new to php coding as you can undoubtedly see from this code, but What I'm trying to do below is Check if get_post_meta( get_theID(), 'jv_item_video1', true ); has been filled in and if it has then show whats in the <iframe></iframe> Upto now the previous part would display a video from the users input, but if they didnt input into that specific field, it would show the frame with a 404 error inside, so I tried to add the if statement. Any help is much appreciated:) <?php $youtube_link = get_post_meta( get_the_ID(), 'jv_item_video1', true ); ?> <?php if (!empty($youtube_link)) { ?> <iframe width="300" height="200" src="<?php echo str_replace('watch?v=','embed/', $youtube_link); ?>" frameborder="0" allowfullscreen></iframe> </div> </div> <?php } ?> Previous - <?php $youtube_link = get_post_meta( get_the_ID(), 'jv_item_video1', true ); ?> <iframe width="300" height="200" src="<?php echo str_replace('watch?v=','embed/', $youtube_link); ?>" frameborder="0" allowfullscreen></iframe> </div> </div> Link to comment https://forums.phpfreaks.com/topic/297843-php-synthax-help/ Share on other sites More sharing options...
Ch0cu3r Posted August 18, 2015 Share Posted August 18, 2015 That code looks fine to me. What is the issue? Link to comment https://forums.phpfreaks.com/topic/297843-php-synthax-help/#findComment-1519147 Share on other sites More sharing options...
alanzap Posted August 18, 2015 Author Share Posted August 18, 2015 Thanks for looking, If the field is filled it shows the video's no problem, but if it's empty, it's showing the frame with a 404 error. Link to comment https://forums.phpfreaks.com/topic/297843-php-synthax-help/#findComment-1519152 Share on other sites More sharing options...
Ch0cu3r Posted August 18, 2015 Share Posted August 18, 2015 What is the output of var_dump($youtube_link); Link to comment https://forums.phpfreaks.com/topic/297843-php-synthax-help/#findComment-1519154 Share on other sites More sharing options...
alanzap Posted August 18, 2015 Author Share Posted August 18, 2015 Thanks Ch0cu3r, looking at the result of that made me see an earlier error. Have it sorted now. Much appreciated! Link to comment https://forums.phpfreaks.com/topic/297843-php-synthax-help/#findComment-1519156 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.