• Resolved gasurgaelach

    (@gasurgaelach)


    I am currently trying to create a ‘Similar Posts’ type section at the bottom of some of my posts. Would anyone be able to tell me how to add a featured image? At the minute, I’m using the details code:

    <?php foreach(get_field('lyrics_appears_on') as $post_object): ?>
    <a href="<?php echo get_permalink($post_object->ID); ?>"><?php echo get_the_title($post_object->ID) ?></a>
    <?php endforeach; ?>

    But the the various post thumbnail snippets don’t seem to work. I’m guessing this is because they don’t pull the post ID like the snippets above. Is there any way I can add an image to the code above? I’ve tried this, but it’s just a stab in the dark..

    <?php wp_get_attachment_image( $post_object->ID, $thumbnail ); ?>

    Thank you! 🙂

    http://wordpress.org/extend/plugins/advanced-custom-fields/

Viewing 1 replies (of 1 total)
  • Thread Starter gasurgaelach

    (@gasurgaelach)

    Hi all, I didn’t know of a cool wee WordPress function ( wp_get_attachment_thumb_url ), sorry for the post!

    Here’s what I’m using:

    <img src="<?php echo wp_get_attachment_thumb_url(get_post_thumbnail_id($post_object->ID)); ?>" alt="<?php echo get_the_title($post_object->ID) ?>" />

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Advanced Custom Fields] Post thumbnail output with Post Object’ is closed to new replies.