Title: Conditional Statement to Load Images
Last modified: August 21, 2016

---

# Conditional Statement to Load Images

 *  [tfagency](https://wordpress.org/support/users/tfagency/)
 * (@tfagency)
 * [13 years ago](https://wordpress.org/support/topic/conditional-statement-to-load-images/)
 * I am trying to figure out how to trigger an image load with a conditional statement.
 * I’ve created a custom field (‘project_match_indicator’) with the true/false conditions
   mapped to ‘matched’ and ‘unmatched’. Wrote this code calling meta info:
 *  <?php if (get_post_meta($post->ID, ‘project_match_indicator’, true) ) {
    echo
   wp_get_attachment_image( 417, ‘full’ ); } else { echo wp_get_attachment_image(
   414, ‘full’ ); } ?>
 * Obviously the ‘true’ in the above is incorrect — it just loads the ID=417 graphic
   for every post. I need to attribute this to ‘matched’ to indicate the checked
   box. It’s like I need an array of some kind.
    Any ideas about how this could 
   be rewritten?
 * [http://wordpress.org/extend/plugins/advanced-custom-fields/](http://wordpress.org/extend/plugins/advanced-custom-fields/)

The topic ‘Conditional Statement to Load Images’ is closed to new replies.

 * ![](https://ps.w.org/advanced-custom-fields/assets/icon.svg?rev=3207824)
 * [Advanced Custom Fields (ACF®)](https://wordpress.org/plugins/advanced-custom-fields/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-custom-fields/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-custom-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-custom-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-custom-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-custom-fields/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [tfagency](https://wordpress.org/support/users/tfagency/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/conditional-statement-to-load-images/)
 * Status: not resolved