Viewing 4 replies - 1 through 4 (of 4 total)
  • 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 for instance.

    Peter

    Thread Starter demka

    (@demka)

    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

    (@demka)

    It’s working now Peter, thank you

    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.