views:

89

answers:

1

I'm outside the loop and want to call a custom value "featvideo" and display it. If there isn't "featvideo" then print an image...

The video displays, but when there isn't a video a blank box displays. You can see the the issue here: http//wgl.buildthesis.com

(and yes, $images is a function defined in functions.php and works)

<?php
     $feat_catbox_1 = new WP_Query("cat=$tt_feat_id&showposts=$tt_feat_postcount"); 
     while ($feat_catbox_1->have_posts()) : $feat_catbox_1->the_post();
     $key = 'featvideo'; 
     $video_url = get_post_custom_values($key); 
     $featuredvideo = $video_url[0];
?>
     <div class="contentdiv">    
            <div id="featured-thumb">
        <?php if ($key=="featvideo")
             echo $featuredvideo;     
            elseif ($key=="") 
               echo $images('1', '390', '244', 'alignleft', true); ?>
             </div>
    </div>
+1  A: 

Since you have set $key = 'featvideo' and then test if it is set later, it will always return true. You never change the value of $key anywhere in your code except when you set it.

I would suggest something like the following for your if statement:

<?php 
if($featuredvideo)
     echo $featuredvideo;
else 
     echo $images('1', '390', '244', 'alignleft', true);
?>
Doug Neiner
I follow you. I delted $key = 'featvideo';and replaced with your code. See: http://wgl.buildthesis.comNow I get a blank screen. I know we're close!
Greg
Sorry Greg, deleting `$key = 'featvideo'` was not what was important as much as that you tested for it but never changed it. Keep all your original code the same, just use my `if` statement instead of your original one.
Doug Neiner
Got it, had to change 'echo $images...' to 'echo images...'Thank you for your help!
Greg