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.
get_post_meta(get_the_ID(),'thumb',true);
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:
<?php
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.