Home Forums General Issues Adding an Image with a “Choice” field


Adding an Image with a “Choice” field

  • I have an Image, that gives the photographer credit, that I would like to be able show depending on the Photograph. Is there a way to set it up so that when I select a “Choice” field that the photo credit will show depending on the choice? Ex: Radio button “Give credit to Photographer: ” yes | no. And the Image has to link to the Photographers web site.

  • I don’t think what you’re looking for is possible with a single field. I would probably do something like the following.

    You would need your Yes/No field.

    If the image can be different then you’d need an image field and a URL field. These would be conditional fields that only show if you’ve selected “yes” in the above field.

    In the template you’d need to test the yes/no field and then display or not display the image and link base on whether it is yes or no.

  • After some more thought, you could add custom fields to the image attachment itself.

    Location: Attachment : is equal to : all

    and then you can use the attachment id to get the data for the specific image. More information is here: specifically the section on “Retrieve from another image custom field”

  • Thank you for your help. I ended up just using a true/false custom field with an if/else statement. Being it was only on one custom post type I just added the php in post type.

    <?php if( get_field('image4') ) { echo "Photo's taken by: <a href=''><img src='http://photolinkhere.jpg' /></a>"; } else{} ?>

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Adding an Image with a “Choice” field’ is closed to new replies.