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)
Viewing 1 replies (of 1 total)
The topic ‘Simple Else if Statement’ is closed to new replies.