Forums

[resolved] custom field in template (5 posts)

  1. sazuka09
    Member
    Posted 2 years ago #

    Good morning everyone,

    I tried to follow some tutorials but some are specified to meta tags etc..

    I just wanted to have a simple custom field ex. IMGURL and be able to add url links inside.

    What I dont know is how to put it inside the template

    <img src="$IMGURL">
    something like that...

    Hope someone can help me a bit... Thank you

  2. sazuka09
    Member
    Posted 2 years ago #

    I tried this as well:

    <?php $image = get_post_meta($post->ID, 'Image', true); ?>
    
    <img src="<?php echo $image; ?>" alt="" />

    But it showed only empty <img src="">

  3. MichaelH
    Volunteer
    Posted 2 years ago #

    You are using that inside a $post loop correct.

    Do echo 'post id: '.$post->ID; to make sure there's something there.

    If necessary, please paste all the code from the template file into a pastebin such as wordpress.pastebin.com, and report the link back here. Maybe someone can spot your problem. Thanks.

  4. sazuka09
    Member
    Posted 2 years ago #

    I tried the echo:
    echo 'post id: '.$post->ID;

    and the results were correct actually:

    <img src="post id: 231" alt="" />

    seems like the custom field just doesnt want to show up..?

  5. MichaelH
    Volunteer
    Posted 2 years ago #

    Or there is not an "Image" custom field for that post.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.