Support » Plugins » Custom Field Issue

  • Basically I have created a new Custom Field called ‘postimage’ which stores the URL of an image which I would like to use unique to that post. Stores as a value such as http://localhost.com/images/58.gif for instance.

    I am using the below code and get_post_meta template tag to extract the information necessary but am going wrong somewhere:

    <div class="categoryimage"><a href="<?php the_permalink() ?>" rel="category tag" title="Image of '<?php the_title(); ?>'"><img src="<?php get_post_meta($post->ID, "postimage", true); ?>" alt="Post Image" class="catimage" /></a></div>

    This code is placed within The Loop, yet whenever I try to view a post the following output is produced, as an example:

    <div class="categoryimage"><a href="http://localhost/?p=58" rel="category tag" title="Image of 'Syndicate!'"><img src="" alt="Post Image" class="catimage" /></a></div>

    Where basically the “postimage” custom field of http://localhost.com/images/58.gif is not being found despite the fact it is displayed when I view the Manage Post area.

    Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • add an “echo” before “get_post_meta”:

    <div class="categoryimage"><a href="<?php the_permalink() ?>"
    rel="category tag" title="Image of '<?php the_title(); ?>'">
    <img src="<?php ECHO get_post_meta($post->ID, "postimage", true); ?>"
    alt="Post Image" class="catimage" /></a></div>

    Isn’t there a “post_image” plugin already?
    http://guff.szub.net/2006/02/09/post-image/

    Thanks I hadn’t noticed this plugin before, however it looks as though this plugin only supports images which are saved as attachments on the server, and what I wanted to do was use images stored externally on websites such as FlickR/Photobucket instead.

    Does anyone know the conditional string I would need to use so that this code would only be displayed when there was infact content in the “postimage” custom field? Since I am using this in the TheLoop.php, and am also using SearchEverything plugn – which means that this post image is trying to be shown for pages/comments which do not have a post image assigned to them.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Field Issue’ is closed to new replies.