Home Forums Plugin Support WP User Frontend Pro Display images in posts

This topic is: resolved

Tagged: , ,

This topic contains 5 replies, has 2 voices, and was last updated by  hatchmedia 5 years, 11 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2729

    hatchmedia
    Participant
    Post count: 116

    Hi guys,

    Hopefully an easy one.  I am just looking to display my images on my posts.  I am currently displaying the Feature Image using the code:
    `< ?php if (has_post_thumbnail( $post->ID )): ?>
    < ?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘full' ); ?>

    <?php
    $images = get_post_meta( $post->ID, 'mey_key_name' );
    if ($images) {
        foreach ($images as $attachment_id) {
            $thumb = wp_get_attachment_image( $attachment_id, 'thumbnail' );
            $full_size = wp_get_attachment_url( $attachment_id );
            printf( '<a href="%s">%s</a>', $full_size, $thumb );
        }
    }
    ?>
    …as per the help documents but to no avail.
    I hope you can help!
    Damien
#2732

Tareq Hasan
Keymaster
Post count: 2831

The code is working fine, just tested. May be you missed something, check again 🙂

#2734

hatchmedia
Participant
Post count: 116

Should I be replacing the Featured Image code or adding to it? 🙂

….because I have tried both ways now and cant seem to get it working for some reason!

#2738

hatchmedia
Participant
Post count: 116

Oh Tareq!

I am being stupid!  I never changed the name of my ID to what my custom fields are called.  Simple simple mistake but hopefully it might help people in the future!

Damien

 

#2741

Tareq Hasan
Keymaster
Post count: 2831

That code is for showing the images from a custom field. Are you using any custom field for the images? Otherwise that won't work.

#2742

hatchmedia
Participant
Post count: 116

Hey Tareq,

All ok now, I had just not included the custom field ID.  Its working now for me!

Thanks again!

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Display images in posts’ is closed to new replies.