This topic contains 7 reply and 2 voices, and was last updated by Nayem 4 years ago
Viewing 7 Posts - 1 through 7 (of 7 total)
Author Posts
September 29, 2015 at 10:55 pm 73467
Nayem Hello, How can I get from a field which have multiple uploads only the first image; Thanks!
October 1, 2015 at 12:59 pm 73666
Nayem Nayem

Hello Paris,

I am not clear about your question. If you will upload multiple images then all those images will appear on the post. Now, please let me know about your query.

October 1, 2015 at 2:41 pm 73680
Paris M Paris M

Hello Naymen,

$images = get_post_meta( $post->ID, 'my_custom_field' );
 
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 );
    }
}

According to this code, upload 10 photos and the question is: how can just pull a photo from the 10 photos?

Thanks!

October 1, 2015 at 4:27 pm 73707
Nayem Nayem

Hello,

Please make me confirm that when do you want to pull the photo? During submit the post or editing the post?

October 1, 2015 at 4:42 pm 73712
Paris M Paris M

During submit the post display

October 1, 2015 at 5:13 pm 73718
Nayem Nayem This reply has been marked as private.
October 1, 2015 at 5:39 pm 73725
Paris M Paris M

Sorry I did not mean to the submit form, but in display of a product..

Thanks!

October 1, 2015 at 5:55 pm 73731
Nayem Nayem

You are posting a WooCommerce product by using Wp user frontend form. So above solution will work.

Viewing 7 Posts - 1 through 7 (of 7 total)