I’m redesigning the website for a Mindfulness Practice Center in New Hampshire, Morning Sun Community, and ran into an issue where I didn’t want the Title on the WordPress page to show if there was a featured image. The layout looks cleaner without the title there (although they opted to have the title appear anyways). The php code I used checks for a header image, then if there is one, do nothing. If there isn’t one, throw the title of the post in there.
<?php //Check if there is a header image if ( has_post_thumbnail( $post->ID ) ) { ?> <?php } else { ?> <h1 class="entry-title"><?php the_title(); ?></h1> <?php } ?>
The code snippet is pretty useful anytime you want to check for a featured image and do something if there is/isn’t one.
Have fun!