How to display all post gallery images in a Query Loop and link them to the CPT post?

Hi everyone,

I have created a Query Loop to display my Custom Post Type (CPT) items. I want to render and filter all images belonging to each post inside a gallery grid (which I already created). When a user clicks on any image, it should redirect them to the corresponding CPT detail page.

Besides the featured image, I created an ACF Gallery field named fotos where I upload additional images for each post.

What is the best way to achieve this in Bricks Builder? Thanks in advance for your help!

Hi,
If I understand your setup correctly, you can load the images (featured image and ACF gallery) using a media query.

Basically, you have two loops: the outer one retrieves the posts as usual, and the inner one retrieves the images:

To link to the post, you can simply wrap the gallery grid in a div or block element and use {post_url} as usual (because post_url refers to the outer loop). You don’t need to link every single image, since the destination is always the same.