Created
June 3, 2013 15:51
-
-
Save mustardBees/5699128 to your computer and use it in GitHub Desktop.
WordPress template snippet to display an image from a CMB file field. Make sure you've registered your CMB field with 'save_id' => true. When the field is saved, the attachment ID will be saved in a custom field and can be accessed by appending _id to your chosen custom field id.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $attachment_id = get_post_meta( get_the_ID(), '_cmb_image_id', true ); ?> | |
<?php if ( ! empty( $attachment_id ) ) : ?> | |
<?php echo wp_get_attachment_image( $attachment_id, 'thumbnail' ); ?> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment