• i am trying to retrieve a custom field (an image in this case) from a specific post. I can bring the custom field in, but it’s not from the post I want. I have tried a few different options here, and I finally came up with this:

    <?php query_posts('meta_key=post_image_value'); ?><h3><?php the_title(); ?></h3>
    <?php while (have_posts()) : the_post(); ?>
    <img src="<?php echo get_post_meta($post->ID = 23, "post_image_value", $single); ?>"
    
    <?php endwhile; ?>

    Still not right, can anyone see what I am doing wrong here?

    Thanks.

Viewing 1 replies (of 1 total)
  • Are you trying to get the image for the current post? If so, this should work:

    <?php query_posts('meta_key=post_image_value'); ?><h3><?php the_title(); ?></h3>
    <?php while (have_posts()) : the_post(); ?>
    <img src="<?php echo get_post_meta($post->ID, "post_image_value", $single); ?>" >
    
    <?php endwhile; ?>

    Notice that you are missing a closing greater-than to close the img tag.

Viewing 1 replies (of 1 total)
  • The topic ‘Retrieving meta value from a post’ is closed to new replies.