Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

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

#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;

}
?>