Jump to content

PHP synthax help


alanzap

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.