$4
IF statement for a custom field
<?php
if (isset(meta(video_url)))
<p><iframe src="<?php meta(video_url);?>" width="570" height="320" frameborder="0"></iframe></p>
?>with video:
http://ec2-50-16-38-139.compute-1.amazonaws.com/wordpress/2011/03/category1/test-lou/
without:
http://ec2-50-16-38-139.compute-1.amazonaws.com/wordpress/2011/03/category2/this-is-a-test-post/
Louis Gubitosi | 03/23/11 at 1:29pm
| Edit
Previous versions of this question:
03/23/11 at 1:31pm
| 03/23/11 at 1:49pm
The experts have suggested, on average, a prize of $4 for this question.
(5) Possible Answers Submitted...
-

Last edited:
03/23/11
1:33pmPippin Williamson says:Obviously replace "meta" with the actual custom fields function.
<?php
if (meta(video_url) != "" && meta(video_url) != null) { ?>
<p><iframe src="<?php meta(video_url);?>" width="570" height="320" frameborder="0"></iframe></p>
<?php } ?>
Previous versions of this answer: 03/23/11 at 1:33pm
- 03/23/11 1:45pm
Louis Gubitosi says:This was the closest fix so far but its showing the URL and not the video in the iframe.
with video:
http://ec2-50-16-38-139.compute-1.amazonaws.com/wordpress/2011/03/category1/test-lou/
without:
http://ec2-50-16-38-139.compute-1.amazonaws.com/wordpress/2011/03/category2/this-is-a-test-post/ - 03/23/11 1:47pm
Pippin Williamson says:Rather than echoing the video url into the iframe, maybe try just pasting the entire iframe into the custom field instead.
- 03/23/11 1:49pm
Louis Gubitosi says:I'd rather just have the URL and leave the embed code in the template. Is there a way to do that?
- 03/23/11 1:50pm
Pippin Williamson says:Yes, the way that I posted should work for that. Can you paste your exact code, please?
- 03/23/11 1:45pm
-

Last edited:
03/23/11
1:34pmAdamGold says:if( $_POST['yourfield'] != "" ) {
?>
<p><iframe src="<?php echo $_POST['yourfield']; ?>" width="570" height="320" frameborder="0"></iframe></p>
<?php
}- 03/23/11 1:36pm
AdamGold says:Ahh didn't notice you're referring to custom field. In this case, you will have to paste this code inside a loop:
if( get_post_meta('video_url') != "" ) {
?>
<p><iframe src="<?php get_post_meta('video_url');?>" width="570" height="320" frameborder="0"></iframe></p>
<?php
}
- 03/23/11 1:36pm
-

Last edited:
03/23/11
1:54pmDavid Navarrete says:
<?php if ($video = get_post_meta(get_the_ID(), 'video_url', true)): ?>
<p><iframe src="<?php echo $video;?>" width="570" height="320" frameborder="0"></iframe></p>
<?php endif; ?>
you can use http://www.viper007bond.com/wordpress-plugins/vipers-video-quicktags/ and put the video on cfield then call the c-field and use apply filters. like this
<?php echo apply_filters('the_content', $video); ?>
Previous versions of this answer: 03/23/11 at 1:45pm | 03/23/11 at 1:54pm
-

Last edited:
03/23/11
1:38pmSébastien | French WordpressDesigner says:<?php $video=get_post_meta(get_the_ID(), 'video', true);
if($video) { ?>
<p><iframe src="<?php echo $video;?>" width="570" height="320" frameborder="0"></iframe></p>
<?php } ?>Previous versions of this answer: 03/23/11 at 1:37pm | 03/23/11 at 1:38pm
-

Last edited:
03/24/11
8:07amNilesh shiragave says:Use this
<?php if (get_post_meta($post->ID, 'video_url', true)): ?>
<?php
$video = get_post_meta($post->ID, 'video_url', true);
?>
<p><iframe src="<?php echo $video;?>" width="570" height="320" frameborder="0"></iframe></p>
<?php endif; ?>
This question has expired.
Current status of this question: Completed





