WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using meta boxes from WP tuts this tutorial http://wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-3-extra-fields/ everything works fine but I don't know ho to call value from image uploader. In my index.php I used this code

<?php $image_upload = get_post_meta($post->ID, $field['custom_image'], true);?>
<?php print_r($image_upload );?>

and it printed this

Array ( 
    [_edit_last] => Array ( [0] => 1 ) 
    [_edit_lock] => Array ( [0] => 1331586724:1 ) 
    [_thumbnail_id] => Array ( [0] => 152 ) 

And when I write this code:

<?php echo wp_get_attachment_image(152); ?>

It shows completly diferent image. Does someone know what I am doing wrong?

share|improve this question

It appears that $field['custom_image'] isn't passing what you want it to. The returned values do not appear to be correct.

You want to put the key of the meta value you need as the second variable in the get_post_meta() function, for example:

$image_upload = get_post_meta($post->ID, '_my_image_id', true);

Each custom meta field you create has a unique identifier, thats the value you want to pass in.

You should also check to see if the returned value of $image_upload is false, in which case the meta was not set for that particular post.

share|improve this answer
So I solved the problem myself :D I was so stupid :D I forgot to put this code in the loop :D :D <?php $image_upload_id = get_post_meta($post->ID, $field['custom_image'], true);?> <?php $img = $image_upload_id ['custom_image'][0];?> and than just put <?php echo wp_get_attachment_image($img); ?> I am sorry for my stupid fault and question :D – Itachi Mar 19 '12 at 22:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.