Forums

[resolved] How to call a custom field that is an image (4 posts)

  1. Benjamin_SP
    Member
    Posted 4 months ago #

    In the past I called custom fields using this code:

    <? echo get_post_meta($post->ID, 'nameofcustomfield', true) ?>

    But this doesn't work when I try to call an image. I am using a custom field called "thumbnail" and as the value I am using the full path of the image. But when I do this:

    <a href= "<? the_permalink(); ?>" title="<? the_title(); ?>"><img src="<? echo get_post_meta($post->ID, 'thumbnail', true) ?>" /></a>

    No image appears. What is wrong with this code?

  2. iridiax
    Member
    Posted 4 months ago #

    You need the full image URL, not just the image name.

    Oops, I see you say you did use the full path. Be sure to check that it is an absolute URL.

  3. Benjamin_SP
    Member
    Posted 4 months ago #

    It is the absolute path iridiax. I just don't know what's wrong.

  4. Benjamin_SP
    Member
    Posted 4 months ago #

    The problem is solved, I didn't have the if have post statement in my theme. After putting that in the thumbnails are showing fine.

Reply

You must log in to post.

About this Topic