WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
Conditional Statement to Load Images (1 post)

  1. tfagency
    Member
    Posted 1 year ago #

    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/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic