Dynamic Product Images

Hi.

On my single product page I want to display product images (one featured and two from gallery) but I don’t want to use Product Gallery widget.

I want to insert there image widget and dynamically fetch images however in dynamic tag there is only featured image.

How can I do that?

1 Like

Take a look here :slight_smile:

1 Like

Thanks but I want to do it without ACF or other plugins.

I need something like {woo_product_img} I think.

You may adjust code based on your needs :slight_smile: so you just replace dynamic data and you are good to go :wink:

Yes but I don’t know proper tags.

For example, {featured_image} fetches main photo but I don’t know gallery tags.

This may help you :slight_smile:

1 Like

Thanks. I created something similar and I made it work. However, I would prefer it if there was a tag in Bricks.

1 Like

It doesn’t work for me.

Where do you insert the PHP code?

Insert to function.php of your Child Theme (Parent Theme) depends on what you are using. Do not forget to check Code review – Bricks Academy

Thanks for this, exactly what I needed!

Just to add:

Bricks Dynamic Tags:

• Use {post_id} for the image source to pull the correct image.

• Use {post_title} for the alt text, which is often the title of the image file in WordPress.

Benefits of This Approach:

No Need for Custom Functions: By keeping everything within Bricks, you avoid the need for additional custom PHP code in your theme’s functions.php file.

Better Integration: This approach leverages WordPress’s native querying system, which is robust and well-integrated with the rest of WordPress and Bricks.

Dynamic and Flexible: Easily adapts to changes in the gallery without needing to adjust custom code.

:wink:

I did this but nothing happens:

function woo_product_images() {
 global $product; 
 $attachment_ids = $product->get_gallery_attachment_ids(); 
 return $attachment_ids;
}

and use as tag {echo:woo_product_images} in widget Image gallary

maybe you forgot to add this here?

1 Like