Issue with "if" statements
-
Hey WordPress Community!
I’m just wetting my beak here with PHP, and wrote the code below. When the value of my custom field is true, there’s no issue. However, when the value is false the alternate image does not show. I keep trying to figure out what I’m doing wrong, and would appreciate a second set of eyes. Thanks!
<?php $featured_ad = get_post_meta($post->ID, 'featured_ad', true); ?> <h3>This post is inspired by:</h3> <?php if ($featured_ad == true) { ?> <img src=" <?php echo ($featured_ad); ?> " width="912" height="1367" alt="Purple Mountain"/> <?php } else {?> <img src="https://sambuc.us/images/ad-02.png" width="912" height="1367" alt="Purple Mountain"/> <?php }; ?>
- The topic ‘Issue with "if" statements’ is closed to new replies.