title: wordpress: creating a conditional statement to load featured image if it exists else a default image
body: <p>I've searched for similar questions to mine here, but haven't found a thread that helps me.. although I did find help here to get to the point where I am now ;)</p>
  
  <p>I've created a jquery slideshow that pulls images from the featured images in a certain post category. I found the code below here at SO and got it to work to my needs so far, but I'd need to add a conditional statement to it:</p>
  
  <pre><code>if(has_post_thumbnail()) {
  $showImg = wp_get_attachment_image_src( get_post_thumbnail_id ( $post-&gt;ID ), 'xiao-show-img' );
  } ?&gt;
  
  &lt;a href="&lt;?php the_permalink() ?&gt;" title="&lt;?php the_title() ?&gt;" rel="&lt;?php the_excerpt() ?&gt;"&gt;
      &lt;img src="&lt;?php echo $showImg[0]; ?&gt;" title="&lt;?php the_title() ?&gt;" rel="&lt;?php the_excerpt() ?&gt;" /&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p>that works ok, but.. i'd like to use something like below to be able to load a default image into the slideshow, if there is no featured image attached to the post:</p>
  
  <pre><code>&lt;?php
  if(has_post_thumbnail()) { ?&gt;
      &lt;a href="&lt;?php the_permalink() ?&gt;" title="&lt;?php the_title() ?&gt;" rel="&lt;?php the_excerpt() ?&gt;"&gt;
          &lt;img src="&lt;?php the_post_thumbnail() ?&gt;" title="&lt;?php the_title() ?&gt;" rel="&lt;?php the_excerpt() ?&gt;" /&gt;
      &lt;/a&gt; 
   &lt;?php
      } else { 
   ?&gt;
      &lt;a href="&lt;?php the_permalink() ?&gt;" title="&lt;?php the_title() ?&gt;" rel="&lt;?php the_excerpt() ?&gt;"&gt;
          &lt;img src="&lt;?php get_bloginfo("template_url"); ?&gt;/images/xiao-default-image.png" /&gt;;
              &lt;/a&gt;
      &lt;?php }
   ?&gt;
  </code></pre>
  
  <p>I realise that the below example doesn't work.</p>