• I’ve got a number of image URLs in custom fields on pages – I want to be able to display them in image tags.

    I’m using this:

    <img alt="sunset" src="<?php echo get_post_meta($post_id->ID, 'bottom', true) ?>" height="150" width="450" border="0" />

    The result is an empty SRC tag:

    <img alt="sunset" src="" height="150" width="450" border="0">

    The custom field IS in fact returning the URL, but for some reason; it is not displaying. I used exit/var_dump to verify this.

    My functions file is empty, do I need any function code to allow custom fields? or to change any wordpress settings?
    How can I fix this?

    thanks,

Viewing 4 replies - 1 through 4 (of 4 total)
  • try:

    <img alt="sunset" src="<?php echo get_post_meta($post->ID, 'bottom', true) ?>" height="150" width="450" border="0" />

    Thread Starter TheIslander

    (@theislander)

    Hi alchmyth,
    The code you posted is in fact what I have written in the file, yet there are no results.

    any ideas?

    the code that I posted is different from the code you posted – that is the only thing I can see;
    right $post->ID vs. wrong $post_id->ID

    please paste the full code of the template into a http://pastebin.com/ and post the link to it here.

    Thread Starter TheIslander

    (@theislander)

    [edit: I’ve solved it] thanks!

    For Future reference, the problem was as alch rightfully pointed out. $post instead of $post_id; also, one should use ” instead of “”.

    thanks again!

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

The topic ‘Custom Fields Image Problem’ is closed to new replies.