the_post_thumbnail IF ELSE function issue
-
Hello,
I have the following code in my single.php file, which grabs the featured image and displays is as a background image for that post.
<figure class="thumblucas"><?php the_post_thumbnail('slider-post-thumbnail'); ?></figure>I am trying to create an IF function that say, If there is a featured image, display that image using the code above. If there is not one, display a generic chosen image. I have found the following code which would work, but its not working with what I am trying to do.
<?php // Must be inside a loop. if ( has_post_thumbnail() ) { <figure class="thumblucas"><?php the_post_thumbnail('slider-post-thumbnail'); ?></figure>; } else { echo '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/thumbnail-default.jpg" />'; } ?>Is there any way to accomplish something like this?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘the_post_thumbnail IF ELSE function issue’ is closed to new replies.