Getting a custom post type image using ‘get_post_custom’

I am trying to echo the image src of an image I have uploaded for my custom post type outside of the while loop.

I have used the following:

Read More
$custom_fields = get_post_custom($_GET['id']);

I can easily now use this code to get, for example the phone number:

echo $custom_fields['telephone'][0]; // e.g. returns 0800 555 222 

However, when I try to get an image using the same code, all I get back is a number.

echo $custom_fields['logo'][0]; // e.g. returns 247

Doing a var_dump of $custom_fields, it seems as though I cannot load this data outside the loop using this function. Does anybody know what I’m supposed to do here without having to do a loop?

Related posts

Leave a Reply

1 comment

  1. I believe you can get away with

    $image_upload = get_post_meta($post->ID, 'logo', true); // CALL IMAGE
    

    and then display it with

    echo wp_get_attachment_image($image_upload);  // Echo image