Simple IF/Else Question
-
Hi
I have been trying to do the following for a couple weeks now, I read a bunch of Beginner PHP tutorials but still cannot it to work.
Here are two blocks of codes, One displays the WordPress Featured Post Thumbnail and the other Displays thumbnails using Timthumb.
What Im trying to do is, if the WordPress Featured thumb is not available to display the thumbnail via the timthumb code.
Here are the two codes Im trying to add the If/Else to
[ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]
<!--Begin WordPress Featured 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>"> <img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo $thumbnailSrc; ?>&h=125&w=165" alt=""> </a> </div> <?php } ?> </div> <!--end WordPress Featured post thumbnail--> <strong>Insert else statement here</strong> <!--Begin Timthumb thumbnail--> <?php // This will show the image and link the image to the post. Alter the width and height (in both places) to your needs. ?> <?php if ( get_post_meta($post->ID, 'thumb', true) ) { ?> <div class="postthumb"> <a>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><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" /></a> </div> <?php } ?> <!--End Timthumb thumbnail-->Any suggestions would be appreciated
Thankyou
Kind regards
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Simple IF/Else Question’ is closed to new replies.