• Resolved Ravi

    (@ravi9)


    Hello,
    I have created a post form with image upload field. I have allowed maximum 5 images.

    Now I want to display the uploaded images in my theme’s single.php

    I followed your tutorial here:
    https://wedevs.com/docs/wp-user-frontend-pro/frontend/showing-meta-fields-in-frontend/

    It works only when one image is uploaded. If the field has more than one image, it displays no image.

    I have tried following code:

    
    <?php
    $images = get_post_meta( get_the_ID(), 'image_upload2' );
    if ( $images ) {
    	foreach ( $images as $attachment_id ) {
    	$thumb = wp_get_attachment_image( $attachment_id, 'full' );
    	$full_size = wp_get_attachment_url( $attachment_id );
    	printf( '<a href="%s">%s</a>', $full_size, $thumb );
    }
    }
    ?>
    

    I have also tried the shortcode:

    
    <?php echo do_shortcode( '[wpuf-meta name="image_upload2" type="image"]' ); ?>
    

    Regards:
    Ravi

    • This topic was modified 5 years, 4 months ago by Ravi.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @ravi9,

    Can you please check if the issue exists with a default theme like Twenty Nineteen?

    Because from our end we can see the images appear in the frontend with both one and multiple images. So I need to know the theme you are using.

    Regards,

    Thread Starter Ravi

    (@ravi9)

    This do not work in default themes also.

    I have tested this code in two default themes.
    Twenty Twenty and Twenty Nineteen

    This code works when:
    Only one image is uploaded.

    Hello,

    Do you have ACF plugin installed and activated on your site? Please let me know.

    Please remove all the custom code you have added and for one final check, please deactivate your existing WP User Frontend plugin’s free version and then install and activate it from scratch. Then check if the issue exists.

    Regards,

    Thread Starter Ravi

    (@ravi9)

    1) ACF plugin is NOT installed.

    2) I have tested this on a fresh wordpress installation with no plugins.

    3) I do not have any custom code on my fresh installation.

    4) I am using the above code in single.php (/templates-parts/content-single.php) to display images.

    Regards:

    Hello @ravi9,

    We are unable to find the same issue from our end so we need to check your site to spot the issue.

    If possible, please allow us to check your site. Since this platform is unable to allow us to check your site, you can contact us so that we can check your site and fix the issue as required.

    Regards,

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display Multiple Images in theme template file’ is closed to new replies.