Bricks Builder Query Editor Loop code for Image Advanced
Support › Meta Box AIO › Bricks Builder Query Editor Loop code for Image AdvancedResolved
- This topic has 3 replies, 2 voices, and was last updated 2 months, 2 weeks ago by
Jeffrey Snelling.
-
AuthorPosts
-
February 4, 2025 at 4:41 AM #47581
Jeffrey Snelling
ParticipantHi All, I'm a recent convert from ACF Pro to Meta Box AIO. I have a site I converted, which had an ACF image gallery, which is now Image Advanced in Meta Box. I'm using Bricks Builder and have a slider that uses a query look (custom code in the Query Editor) to pull the images from the ACF image gallery. Trouble is, now that I have migrated, that no longer works obviously, but I'm have a heck of a time finding code that would work with Image Advanced. The website page where I'm using the slider is here: https://jeffreys234.sg-host.com/quirkle/botanist-bert/
Any recommendations on how to get this to work?
The code I'm using in the Query Editor is:
/* use image advanced field id from MetaBox */
$mb_images = rwmb_get_value("character_image_gallery");if (!empty($mb_images)) {
return [
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'orderby' => 'post__in',
'post__in' => $mb_images,
'posts_per_page' => -1,
];
} else {
return [];
}February 4, 2025 at 11:14 PM #47587Peter
ModeratorHello Jeffrey,
The helper function rwmb_get_value() will return some additional information to the value like image info, not only the image IDs so if you pass the value to the argument
post__in
, it might not work.I suggest you use the WordPress function get_post_meta() or add a specific post ID to this function to see if it works.
February 5, 2025 at 2:06 AM #47592Jeffrey Snelling
ParticipantThanks Peter. I did try using get_post_meta, but I couldn't get it to work. Here's the code I tried (using both true and false as the 3rd parameter). I also tried with an extra statment to get ids only, but that's not working either. It's hard to believe this is so difficult.
$post_id = get_the_ID(); // Get current post ID
$meta_key = 'character_image_gallery'; // field ID for Image Advanced field
$mb_images = get_post_meta($post_id, $meta_key, true);
$mb_image_ids = array_keys($mb_images); // get id's onlyif (!empty($mb_images_ids)) {
return [
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'orderby' => 'post__in',
'post__in' => $mb_images_ids,
'posts_per_page' => -1,
];
} else {
return [] ;
}February 5, 2025 at 4:17 AM #47593Jeffrey Snelling
ParticipantHi Peter, I posted this same question in the Inner Circle (https://circle.digitalambition.co/) and got some good feedback. Just in case others are looking for this, I'll post the link here to the solution, which was just solved with the latest release of Bricks Builder: https://academy.bricksbuilder.io/article/query-loop/#query-loop-for-metabox-image-field
For those that have BricksExtras installed, they also have a solution here:
https://bricksextras.com/docs/gallery/Thanks for the help.
Cheers,
Jeff -
AuthorPosts
- You must be logged in to reply to this topic.