Title: Simple Else if Statement
Last modified: August 20, 2016

---

# Simple Else if Statement

 *  [icey7](https://wordpress.org/support/users/icey7/)
 * (@icey7)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/simple-else-if-statement/)
 * Hi
 * Thankyou for reading.
 * I have a small code which displays post thumbnails, I would like to add an else/
   if statement so if this first method of creating thumbnails fails it create thumbnails
   using a second method.
 * Here is what Im using so far to create thumbnails:
 *     ```
       <!--Begin post thumbnail-->
       <div class="postthumbcon">
       <?php
       // check if the post has a featured image assigned to it.
       if ( has_post_thumbnail() ) {
       // get the src of the large size featured image
       $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' );
       $thumbnailSrc = $src[0];
       // output image resized with timthumb
       ?>
       <div class="postthumb">
       <a href="<?php the_permalink(); ?>">
       <img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo $thumbnailSrc; ?>&h=125&w=165" alt="">
       </a>
       </div>
       <?php } ?>
       </div>
       <!--end post thumbnail-->
       ```
   
 * **Here is where I would like to add the Else/if**
 * This next code is the Second method of creating thumbnails:
 *     ```
       <?php if( get_post_meta($post->ID, "thumb", true) ): ?>
       <div class=”homethumb”>
       <img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&h=150&w=150&zc=1" alt="<?php the_title(); ?>" width="150" height="150" />
       </div>
       <?php else: ?>
       <?php endif; ?>
       ```
   
 * Thankyou again
    Kind regards

Viewing 1 replies (of 1 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/simple-else-if-statement/#post-2915137)
 * try and see if you can get on with this php tutorial:
 * [http://php.net/manual/en/control-structures.elseif.php](http://php.net/manual/en/control-structures.elseif.php)

Viewing 1 replies (of 1 total)

The topic ‘Simple Else if Statement’ is closed to new replies.

## Tags

 * [else](https://wordpress.org/support/topic-tag/else/)
 * [if](https://wordpress.org/support/topic-tag/if/)
 * [thumbnails](https://wordpress.org/support/topic-tag/thumbnails/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [13 years, 11 months ago](https://wordpress.org/support/topic/simple-else-if-statement/#post-2915137)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
