• I am trying to code out the if statement to output secondary image if present or set a default image. This is my current code:

    <?php if (has_post_thumbnail($post->ID)) :
    $image = MultiPostThumbnails::get_post_thumbnail_url(get_post_type( $post->ID ), ‘secondary-image’);
    else :
    $image = ‘https://noviastrategies.com/wp-content/uploads/2015/01/insights2.jpg&#8217; ;
    endif; ?>
    <div id=”secondary_area” style=”background-image: url( ‘<?php echo $image; ?>’ )”>

    I can output the secondary image, but the default will not show if secondary image is not present. Any advice?

    Website is: https://noviastrategies.com

  • The topic ‘PHP If statement for secondary image or default image.’ is closed to new replies.