Home › Forums › Other › How to make PHP "if" code to display:none if a featured image is not set › Reply To: How to make PHP "if" code to display:none if a featured image is not set
March 26, 2017 at 4:03 am
#253173
Konspaul
Participant
Thanks for your help.
This was actually solved simply by adding an if statement to the php like so:
<?php
// Add featured image on single post
add_action( 'genesis_before_content', 'jaana_featured_image', 1 );
function jaana_featured_image() {
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
if ($thumb):
?>
')">
<?php
else:
?>
<?php
endif;
}
?>