How To Display A Custom Image Field Uploaded Via WordPress Media
If you have created a custom field to upload images using WordPress media browser, this custom field is added to a post as an attachment. Calling this custom field using the standard get_post_meta returns the attachment’s ID. This is inserted into mySQL post table with its guid of the image file.
To display the actual image, you would using the following:
// Change "my_custom_photo" to the slug of your custom field $photo = get_post_meta( get_the_ID(), 'my_custom_photo', true ); // Change "medium" to the thumbnail size used in your theme $photo = wp_get_attachment_image( $photo, 'medium' ); echo $photo;