Forums

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

  1. Benjamin_SP
    Member
    Posted 2 years 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 2 years 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 2 years ago #

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

  4. Benjamin_SP
    Member
    Posted 2 years 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.

Topic Closed

This topic has been closed to new replies.

About this Topic