• Resolved AardvarkGirl

    (@aardvarkgirl)


    I’ve got a space in the header to use the featured image. What I’m trying to do is an if / else that IF there is a featured image, great load that puppy up WITH the html (the div). If there is no featured image, don’t put anything (no div).

    Why? The client wants to be able to upload a photo there, and the photo is held in a div that has a white background, a 5px padding all the way around, and a drop shadow. This way they don’t have to know how to edit graphics or send the photos to me.

    http://www.ratest6.com/about-us/

    If there is no featured image the div is showing up as a small white square (because it has the white background and 5px of padding).

    http://www.ratest6.com/links-and-resources/

    Right now I’ve got:

    <div class="banner">
             <?php
        if(has_post_thumbnail()){
            the_post_thumbnail('full');
        }
        else{
            echo '';
        }
    ?>
    </div><!-- end of banner -->

    Or, if there is a css solution I’m all ears too. 🙂

Viewing 1 replies (of 1 total)
  • Thread Starter AardvarkGirl

    (@aardvarkgirl)

    Never mind, I worked it out:

    <?php
      if(has_post_thumbnail())
    	{echo'<div class="banner">';
            the_post_thumbnail('full');
         echo '</div>';}
    
      else{
         echo '';
        }
    	?>
Viewing 1 replies (of 1 total)
  • The topic ‘Need help with if – else statement for featured image’ is closed to new replies.