Verve Meta Boxes
Custom Fields Content not Showing up (7 posts)

  1. dorono
    Posted 5 years ago #

    I'm using this in conjunction with the Custom Post Types UI plugin, have Custom Post Types UI set to 'Supports Custom Fields,' have added an image upload field to my page, and then inserted <?php get_post_custom_values('img_upload'); ?> into my custom post type template. (img_upload being my custom field key)

    However, the image isn't appearing on the page. I've also attempted to try different field types, but those didn't show up either.

    I deactivated all of my plugin, still no result.

    I tried switching themes, no result.

    Tried it on a different site altogether and actually got a bunch of PHP errors.

    Not sure if anyone else is having this experience, but for the life of me I can't seem to fix it.

    Any ideas would be awesome. Thanks!


  2. avenueverve
    Plugin Author

    Posted 5 years ago #

    hi doron,

    You need to echo the value
    <?php echo get_post_custom_values('img_upload'); ?>

    and then really, you would want to echo it inside an image tag:
    <img src="<?php echo get_post_custom_values('img_upload'); ?>">

    something like that


  3. dorono
    Posted 5 years ago #

    Thanks for the response!

    Unfortunately this plugin still doesn't work for me.

    Tried putting <?php echo get_post_custom_values('img_upload'); ?> as well as <img src="<?php echo get_post_custom_values('img_upload'); ?>"> within the loop of my custom post type template to no avail.

  4. M.A.D
    Posted 5 years ago #

    Hello Dorono,

    I found that the following made it work;

    Store array in a variable
    <?php $img = get_post_custom_values('img_upload'); ?>

    And then echo out the array as follows
    <img src="<?php echo $img[0]; ?>">

    More on storing and outputting arrays can be found here

  5. dorono
    Posted 5 years ago #

    Ahh, ok, thanks. Will give it a try asap!

  6. catnip216
    Posted 5 years ago #

    Also try this to keep it a one-liner:

    <?php echo get_post_meta($post->ID, 'img_upload', true); ?>

    The first parameter passes the current post/page ID, the second one is the name of the metakey you need, and the third is for whether or not you want to force it to return just a single value, instead of an array. (True = single value, false = array).

  7. redkitecreative
    Posted 5 years ago #

    I've tried all the suggestions in this thread and none are working for me.

    The image is uploaded, it shows up fine in the backend but in the frontend, I either see nothing or I get just a link to the image, such as with this code:

    ID,'image',true); ?>" />"><img src="<?php echo get_post_meta($post->ID,'image',true); ?>" />

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic