April 13, 201511 yr Can anyone tell me why my ELSE statement is showing if my IF statement is true? <?php if ( !empty(the_post_thumbnail()) ) { the_post_thumbnail( 'full', array( 'class' => 'img-responsive' ) ); } else { echo "<div class='page-header'><h1>" . the_title() . "</h1></div>"; } ?>
April 13, 201511 yr With WP you need to use has_post_thumbnail(), for example: if ( has_post_thumbnail() ) { the_post_thumbnail(); } else { //Something else } the_post_thumbnail is a function, so you can't use "empty" in a conditional statement the way you would do with a field, if that makes sense
Create an account or sign in to comment