Support » Fixing WordPress » Trouble with 2.5 and Custom Fields

  • Okay this is making me tear my hair out…..I’ve spent this entire day reading this forum and trying every suggestion I could find and it’s still not working….

    I’m trying to display a thumbnail image that is entered as a custom field. I’ve verified that the image is entered correctly in the post’s custom fields, as such:

    key=thumb, value=””

    I’ve verified that the file is indeed in the uploads folder

    I’ve enter the php code where I want it to go as this:

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

    I’ve also, as said, tried every other iteration suggested that I could find in combin thru these forums, all to no avail. When I view the source of the resulting page, I see my image referenced empy, like this:

    `<img src=”” />

    Is this a bug, or has something changed with 2.5 in how you display images contained in custom fields?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Bump…..I still really need help with this……anyone?

    Have you tried to echo $post->ID and make sure that it’s set correctly? I mean, that is valid, but it also assumes you’re using the global $post, which you might not be depending on your context.

    For getting the ID of the current post in the Loop, you should really use get_the_ID() instead.


    Thanks Otto – I appreciate the response……

    I should have been a little more clear in how this is being used…

    This is for a shopping cart page (using the YAK plugin) – all is working fine but I’ve been asked to show a product thumbnail next to each item in the cart….

    The query that sets up to display the items in the cart reads like this:

        foreach ($_SESSION["items"] as $key => $item) {
            $price = yak_calc_price($item->id);
            $item_price = $price * $item->quantity;
            $total_price += $item_price;
            $qtyid = 'item_' . $item->id . '_' . $item->cat_id;

    Then in the table cell where the item appears is this code:
    <a href="<?php echo $_SERVER[PHP_SELF] . '?' . $item->id_type . '=' . $item->id ?>"><?php echo $item->name ?></a>

    So in the next table cell I’ve been trying to add the code to display the thumbnail image, with no success. I did try the code you suggested but still get <img src=”” />

    Does this change what you would suggest I do?

    Anyone? I’m under a deadline and getting desperate…..

    Sorry I hate to keep bumping this but I really need help with this one….

    Another bump – I still need help – have been trying everything I can think of here….

    Does this change what you would suggest I do?

    Probably, but I still don’t know what the heck it is that you’re doing.

    get_post_meta works, if you have the correct post ID. But I don’t know anything about a shopping cart or anything like that. This is a WordPress forum. We only know WordPress.

    Thanks Otto

    This actually is in WordPress, and even though I’m using a shopping cart plugin (YAK Shopping Cart plugin), I’m still trying to use a standard WordPress function to display an image in a custom field.

    I think the problem is that this function is not being called from within The Loop, so I’m not sure exactly how to display custom fields from outside of the Loop…..I’m really a coder.

    So maybe if someone call tell me if and how to display a custom field outside of the Loop that might solve my problem.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Trouble with 2.5 and Custom Fields’ is closed to new replies.