23rd Mar '23
/
3 comments

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

Get access to all 626 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Meta Box Date Field Value Custom Format in Bricks

Meta Box Date Field Value Custom Format in Bricks

Updated on 3 Apr 2024 Note: A custom function is no longer needed. Use the date format filter, as mentioned in the Bricks documentation. Ex.:…
Categories:
Tags:
Pro
Current Post’s Terms in Bricks

Current Post’s Terms in Bricks

Updated on 15 Jan 2024 This Pro tutorial provides the steps to set up a grid of terms (like categories) that the current post is…
Pro
Programmatically populating ACF field values in WordPress

Programmatically populating ACF field values in WordPress

An example of how to set the values of a Select-type field with the names and labels of all public post types.
Categories:
Pro
Top-level Pages and Children Bricks Query Loop

Top-level Pages and Children Bricks Query Loop

This Pro tutorial for Bricks users can be considered Part 2 or a variation of the earlier Bricks Query Loop for Top-level Parent Pages with…
Categories:
Pro
Setting a Bricks template for Parent pages

Setting a Bricks template for Parent pages

This Pro tutorial shows how bricks/active_templates filter can be used to programmatically assign a Bricks template to all singular pages (of any post type) that…