This piece of code:
<img src=”<?php bloginfo('url'); echo '/'; echo get_option('upload_path'); echo '/';
// this is where the Lead Story image gets printed
$values = get_post_custom_values(”leadimage”); echo $values[0]; ?>” alt=”leadimage” id=”leadpic” /></a>
Are producing an empty image space in my theme. I just don't understand where to look for this image, or how to add it?
I am using the Branford Magazine theme. Yes, I have asked, but got no answere.
CounterDax
Member
Posted 4 years ago #
As far as I can tell, the "leadimage" is a custom key and should thus have a value referring to the image itself (an URL).
When you write a new post (or edit a current one), open the little area marked CUSTOM FIELDS, type leadimage in the field for key, and type an URL to an image in the value field.
I just wonder why $values is an array...
CounterDax: Please recieve a big virtual ale from me!!! :-)
CounterDax
Member
Posted 4 years ago #
For all PHP newbies: Just move `// this is where the Lead Story image gets printed
$values = get_post_custom_values(”leadimage”);` to before the start of the image element and wrap everything up in an if statement if you want to check whether the image actually exists.
Out of my head:
<?php $values = get_post_custom_values("leadimage");
if(!empty($values)) { ?>
<img src=”<?php bloginfo('url'); echo '/'; echo get_option('upload_path'); echo '/';
echo $values[0]; ?>” alt=”leadimage” id=”leadpic” /></a>
<?php } // end leadimage ?>
I see that there must be an anchor (<a href=) before the image. Don't forget to paste that, too.
eibhlin
Member
Posted 4 years ago #
Also see my step-by-step directions for leadimage, Lead image (or any Custom Fields image in Branford Magazine or Mimbo) in this comment:
http://wordpress.org/support/topic/166831?replies=8#post-736000