get_post_meta not working properly for img tag
-
Hi,
This has been discussed in many threads but no one seems to have a satisfactory answer. I am doing a wordpress custom theme building course (which uses version 3.0) and the section i am dealing with is the template page. In this page I have following code:<?php get_header(); the_post(); ?> <div id='main-content'> <h2 class="product-title"><?php the_title(); ?></h2> <div class="product-info-box"> <img src="<?php echo get_post_meta($post->ID, 'product_large', true);?>" alt="new"> <ul> <li><h5>Price</h5> $<?php echo get_post_meta($post->ID, 'Price', true); ?></li> <li><h5>Product Code</h5><?php echo get_post_meta($post->ID, 'Product_Code', true); ?></li> <li><h5>Dimensions</h5> <?php echo get_post_meta($post->ID, 'Dimensions', true); ?></li> <li><a class="button" href="#">Add to Cart</a></li> </ul> </div>
Everything except for the image doesn’t load.
I am using Xampp and the product-images folder is in the root folder of the wordpress files and NOT in the theme.
I checked the source code and the output is
<img src='/product-images/productname.png' />
It did not output what comes before that i.e.D:/folder/xampp/htdocs/worpdress/product-images
…
So quite obviously when you click on the outputted link in the source code it says object not found.I found a fix online where it said I had to use bloginfo(‘url’) before the get_post_meta part. I tried that and it worked. But for the category page I couldn’t implement it because the img tag itself is being echoed.
More importantly I want to know
-
why this is NOT working?
Has wordpress made changes to not support this? This answer would be way more appreciated than an alternate solution.
The instructor uses the same code and it works for him. I am at my wits end trying to get this thing to work. Please help.
P.S. I had commented on other similar posts but was told to post here afresh because those threads were really old. Hoping to get a satisfactory answer here. Thank you.
- The topic ‘get_post_meta not working properly for img tag’ is closed to new replies.