How to use image element to output ACF gallery images

Because the image gallery element outputs images as backgrounds, which is not good for SEO; I want to use the image element to display single images from the ACF gallery and achieve the gallery effect by arranging multiple image elements.

I have tried the two tags {acf_gallery: 2} and {acf_gallery: array_value | 2}, but they don’t work. I don’t know what method can be used to achieve this.

**PS: I have Happyfiles, so there is any way to display dynamic image groups through it?

1 Like
function acfgall ($item) {
  $images = get_field('fajh',false,false);	
  return $images[$item];
}
{echo:acfgall('0')}
1 Like

Thanks for your code. But it seems not to work. Here are some screenshots of mine, not sure if something is set wrong.


snippet
echo

Before giving the solution, I tested it on myself!

Sometimes the code does not output data in the editor, but works on the site.

Aha, I’m not stupid enough to not go to the frontend and check the actual results. :rofl:
In my case: added the ACF field to the woocommerce category and used {echo:acfgall(‘1’)} in the product category template. But it is not outputting any images.

But when I add the ACF field to a page, your code is working.

Maybe something else is a bit wrong.

For the woocommerce cat page, the code @clickfusion63 provided needs to be modified:

function acfgall ($item) {
  $category = get_queried_object();
  $images = get_field('show-product-image',$category,false);	
  return $images[$item];
}
{echo:acfgall('1')}