Aleš Sýkora / August 18, 2025 / 0 comments

Bricks: Loop images from WP ASE Gallery custom field

Post summary: Here’s how to properly query and display gallery images from WP ASE Pro plugin custom field type gallery in Bricks Builder.

The main challenge occurs when gallery image IDs are stored as a string like "1850,1851,1852" instead of an array. Your query loop needs to convert this string into individual attachment IDs that WordPress can understand.

$images = get_post_meta(get_the_ID(), 'your_ase_gallery_field_name', true);
$image_ids = is_string($images) ? explode(',', $images) : (array) $images;
$image_ids = array_filter(array_map('intval', $image_ids));

return [
    'post_type'      => 'attachment',
    'post_status'    => 'inherit', 
    'post_mime_type' => 'image',
    'post__in'       => $image_ids ?: [0],
    'orderby'        => 'post__in',
    'posts_per_page' => -1
];

Put this code in the query editor and change the your_ase_gallery_field_name to your gallery slug. I use it for beter user experience, when creating logo sliders because repeater takes a time to fill when you have more than 5 images…

And for the image field, select post_id in dynamic data inside the query:

Fuel my passion for writing with a beer🍺

Your support not only makes me drunk but also greatly motivates me to continue creating content that helps. Cheers to more discoveries and shared success. 🍻

0 comments

Share Your Thoughts