Support » Plugin: Advanced Custom Fields » 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?

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