Title: Post Image &#8211; Default for None
Last modified: August 19, 2016

---

# Post Image – Default for None

 *  [tylerplack](https://wordpress.org/support/users/tylerplack/)
 * (@tylerplack)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/post-image-default-for-none/)
 * I am using this code:
 *     ```
       <?php
       if ( has_post_thumbnail() ) {
       echo the_post_thumbnail();
       }
       else {
       echo "";
       }
       ?>
       ```
   
 * to get the post thumbnails from the blog. It’s setting up fine, but how do I 
   make it display another image if there is none. You can see it is the PHP if 
   and else statements, but I don’t know how to make to do an image.
 * All help is appreciated!

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/post-image-default-for-none/#post-1382845)
 * Try:
 *     ```
       <?php
       if ( has_post_thumbnail() )  echo the_post_thumbnail();
       else {
       	echo '<img src="http://domain/image.jpg" width="xx" height="yy" alt="" />';
       }
       ?>
       ```
   
 *  [jwesonga](https://wordpress.org/support/users/jwesonga/)
 * (@jwesonga)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/post-image-default-for-none/#post-1383024)
 * I just tried that function `has_post_thumbnail` and got this error:
 * `Fatal error: Call to undefined function has_post_thumbnail() in C:\xampp\htdocs\
   wordpress-2.9.1\wordpress\wp-content\themes\mclabs\inner_page.php on line 11`
 *  [jwesonga](https://wordpress.org/support/users/jwesonga/)
 * (@jwesonga)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/post-image-default-for-none/#post-1383025)
 * Sorry figured it out, I added the `add_theme_support( 'post-thumbnails' );` to
   my functions.php file and it sorted it out
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/post-image-default-for-none/#post-1383052)
 * Sorry. I assumed you already had that in place.
 *  Thread Starter [tylerplack](https://wordpress.org/support/users/tylerplack/)
 * (@tylerplack)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/post-image-default-for-none/#post-1383154)
 * Great, esmi. How can we make this more dynamic?
 *     ```
       <?php
       if ( has_post_thumbnail() )  echo the_post_thumbnail();
       else {
       	echo '<img src="http://domain/image.jpg" width="xx" height="yy" alt="" />';
       }
       ?>
       ```
   
 * See how it says domain/image.jpg? How can I do the `<?php bloginfo('template_url');?
   >` so it will work in all sites, but still inside this code?

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Post Image – Default for None’ is closed to new replies.

## Tags

 * [thumbnail](https://wordpress.org/support/topic-tag/thumbnail/)

 * 5 replies
 * 3 participants
 * Last reply from: [tylerplack](https://wordpress.org/support/users/tylerplack/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/post-image-default-for-none/#post-1383154)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
