Using the pods Multi-image field to populate a nestable slider in Bricks builder
-
Hi, I’m hoping someone might be able to give me a few pointers on this problem, I’ve had no luck asking on the Bricks forum.
I’ve attached a Pods File/Image/Video field to the standard Page type in WordPress, it’s set to accept multiple files. I’ve uploaded a few images to it.
I’m editing the page in Bricks builder and have attached a Nestable Slider to the page and I’m trying to populate the slider from the Pods custom field. I’ve enabled the query loop for the first slide in the slider and I’ve attached a Bricks code element to the page and entered the following code
<?php add_filter( 'bricks/posts/query_vars', 'bricks_query_vars_filter', 10, 3 ); function bricks_query_vars_filter( $query_vars, $settings, $element_id ) { /* Place your loop element id */ if ( $element_id === 'mxxzcg' && function_exists( 'pods' ) ) { global $post; // Assuming 'gallery' is the name of the Pods multi-image field $pod = pods( 'gallery', $post->ID ); // Replace 'your_pod_name' with the name of your Pods if ( ! empty( $pod ) ) { // Retrieve the multi-image field data as an array of image IDs $gallery_ids = $pod->field( 'gallery', true ); if ( empty( $gallery_ids ) ) { /* Make sure that no posts are returned when * there are no images in the gallery */ $query_vars['post__in'] = [0]; return $query_vars; } $query_vars['post__in'] = $gallery_ids; } } return $query_vars; } ?>
I have the following query loop settings under content:
Type: posts
Post Type: Media
Child of: {post_id}And for the Background image, I also have {post_id} set.
The slider is just returning all images attached to the page rather than just the images uploaded to the Pods custom field.
Any help would be great.
- The topic ‘Using the pods Multi-image field to populate a nestable slider in Bricks builder’ is closed to new replies.