Title: Can&#8217;t get image loaded using custom fields
Last modified: August 19, 2016

---

# Can’t get image loaded using custom fields

 *  [demka](https://wordpress.org/support/users/demka/)
 * (@demka)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/cant-get-image-loaded-using-custom-fields/)
 * Hi there
    I need help with my WP-theme. I’m using PRiNZ BranfordMagazine 2.6 
   2.6 (released 2008-12-14) by Michael Oeser and I can’t get my image loaded on
   my front page using custom fields. This is my code, can anyone see anything wrong
   with it? I used “leadimage” as NAME and [http://www.texaslandsurvey.com/wp-content/uploads/2009/12/leadimage.jpg](http://www.texaslandsurvey.com/wp-content/uploads/2009/12/leadimage.jpg)
   as VALUE. Thank you in advance.
 * <!– LEAD ARTICLE –>
    <div id=”fragment-1″> <ul id=”leadarticle”> <?php // Lead
   Story module begins query_posts(‘showposts=1&cat=1’); //selects 1 article of 
   the category with ID 1 ?> <?php while (have_posts()) : the_post(); ?> <?php //
   this grabs the image filename $values = get_post_custom_values(“leadimage”); //
   this checks to see if an image file exists if (isset($values[0])) { ?> ” rel=”
   bookmark” title=”Permanent Link to <?php the_title(); ?>”><img src=”<?php // 
   this is where the Lead Story image gets printed $values = get_post_custom_values(“
   leadimage”); echo $values[0]; ?>” alt=”leadimage” id=”leadpic” /> <?php } ?> 
   <h3> <?php // this is where the name of the Lead Story category gets printed 
   wp_list_categories(‘include=1&title_li=&style=none’); ?> </h3> ” rel=”bookmark”
   title=”<?php __(‘Permanent Link to’,’branfordmagazine’)?> <?php the_title(); ?
   >” class=”title”> <?php // this is where the title of the Lead Story gets printed
   the_title(); ?>  <?php // this is where the excerpt of the Lead Story gets printed
   the_excerpt() ; ?> <span class=”read-on”> ” rel=”bookmark” title=”<?php __(‘Permanent
   Link to’,’branfordmagazine’)?> <?php the_title(); ?>”> <?php _e(‘[continue reading…]’,’
   branfordmagazine’); ?>  </span> <?php endwhile; ?>
 *  </div>
    <!– END LEAD ARTICLE –>

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Peter Boosten](https://wordpress.org/support/users/pboosten/)
 * (@pboosten)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/cant-get-image-loaded-using-custom-fields/#post-1300395)
 * I use get_post_meta() for grabbing values from custom fields, and that’s exactly
   the reason why it doesn’t work. get_post_custom_values() delivers an array, which
   cannot be used in the way you use it.
 * Look [here](http://www.boosten.org/page-templates-in-wordpress/) for instance.
 * Peter
 *  Thread Starter [demka](https://wordpress.org/support/users/demka/)
 * (@demka)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/cant-get-image-loaded-using-custom-fields/#post-1300396)
 * Thank you Peter. I’m sorry I’m very new to this. If I just replace
    // this checks
   to see if an image file exists if (isset($values[0])) { ?> ” rel=”bookmark” title
   =”Permanent Link to <?php the_title(); ?>”><img src=”<?php // this is where the
   Lead Story image gets printed $values = get_post_custom_values(“leadimage”); 
   echo $values[0]; ?>” alt=”leadimage” id=”leadpic” /> <?php } ?>
 * to this
 * // this checks to see if an image file exists
    if (isset($values[0])) { ?> ” 
   rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><img src=”<?php//
   this is where the Lead Story image gets printed $values = get_post_custom_values(“
   leadimage”); echo $values[0]; ?>” alt=”leadimage” id=”leadpic” /> <?php } ?>
 * would it work then? As I said I’m sorry but I’m not quite sure what I’m doing
   with it and I would really appreciate your help.
    Thank you
 *  Thread Starter [demka](https://wordpress.org/support/users/demka/)
 * (@demka)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/cant-get-image-loaded-using-custom-fields/#post-1300397)
 * It’s working now Peter, thank you
 *  [Peter Boosten](https://wordpress.org/support/users/pboosten/)
 * (@pboosten)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/cant-get-image-loaded-using-custom-fields/#post-1300398)
 * Try this:
 *     ```
       <img src="<?php
       // this is where the Lead Story image gets printed
       echo get_post_meta($post->ID, 'leadimage', true); ?>" alt="leadimage" id="leadpic" />
       ```
   
 * Please embed your code in the code tags, that increases the readability about
   600 million times 😉
 * Peter

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Can’t get image loaded using custom fields’ is closed to new replies.

 * 4 replies
 * 2 participants
 * Last reply from: [Peter Boosten](https://wordpress.org/support/users/pboosten/)
 * Last activity: [16 years, 5 months ago](https://wordpress.org/support/topic/cant-get-image-loaded-using-custom-fields/#post-1300398)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
