Get 30% discount on lifetime membership by using BFCM2023 coupon.
Offer ends on 30th Nov 2023 at 11:59:59 PM UTC.

Looping Through a Cloneable Meta Box Sub Field in Bricks

This Pro tutorial shows how a custom query type can be set up in Bricks to render YouTube videos (via the built-in Video element) whose IDs are taken from value of a cloneable sub field of a group field.

We shall first loop through the group field (functionality built in Bricks) and inside that, loop through the sub-field (made possible via custom query type) i.e., make nested query loops.

Scenario:

CPT: course

Meta Box field group:

events field being populated on a course post:

Structure of single course template:

Output on the frontend:

We shall ensure that if the video_id sub field is empty, the entire videos Section does not get rendered.

Step 1

Add this in child theme's functions.php or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Instant access to all 250+ Bricks code tutorials with BricksLabs Pro