alanzap Posted August 18, 2015 Share Posted August 18, 2015 (edited) 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> Edited August 18, 2015 by alanzap Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted August 18, 2015 Solution Share Posted August 18, 2015 What is the output of var_dump($youtube_link); Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.