• Hello

    I would like to get all of the images associated with each post. I tried the code below thus far with no luck:

    ‘if(class_exists(‘Dynamic_Featured_image’)): global $dynamic_featured_image;
    $featured_images = $dynamic_featured_image->get_featured_images(get_the_ID);
    $max = get_field(‘product-total’);
    for($i = 0; $i < $max – 1; $i++):
    $image{$i} = $featured_images[$i];
    echo ‘‘;
    endfor;
    endif;’

    This code is in error. Can someone please tell me how the all images can be retrieved?

Viewing 1 replies (of 1 total)
  • I see two issues in your code:

    1) get_the_ID is a function, so you need to add brackets after it.

    $featured_images = $dynamic_featured_image->get_featured_images( get_the_ID() );

    2) You are viewing an array of featured images, taking the maximum value of the index value from the product-total field. It is likely that for some indexes there will not be images in the array.

    If this does not help, then write the text of the error message. Most likely, there will be a key to solving the problem inside it.

Viewing 1 replies (of 1 total)
  • The topic ‘Want to get all of the images associated with a post’ is closed to new replies.