WordPress.org

Ready to get started?Download WordPress

Forums

Adding custom value next to header (2 posts)

  1. cinnoi
    Member
    Posted 2 years ago #

    Hi,

    I've searched and searched for days, but I've found no answer.

    I have a custom field called "Image" (which is linked to an image) that I want displayed next to my post's title in the single page and on the main page. However, I've no idea how to recall the custom filed or where to display the code that does it.

    I believe <?php $image = get_post_meta($post->ID, 'Image', true); ?> should get the image, but I've no idea where to put the code or how to get it to display.

    Any help would be greatly appreciated.

    FYI. I'm using a child theme and I'm using Twenty Eleven.

    Thanks
    `

  2. bcworkz
    Member
    Posted 2 years ago #

    Hook the filter "the_content". Your function will be passed the entire html for a post. Search for the spot to insert your image and insert the complete "<img src='" . $image . "'>" tag there. Return the updated content and it will all be displayed during the loop.

Topic Closed

This topic has been closed to new replies.

About this Topic