Post sub field Bricks Query Loop in a Meta Box Group field

Post sub field Bricks Query Loop in a Meta Box Group field

Let's consider this Meta Box field group for Pages:

FAQs is a Group-type of field in which one of the sub fields is "Answer Post", a Post-type of field.

"Sample Page" being edited:

On the front end we want to show the question heading and below that, the content (rather the excerpt) of the selected answer post for each question as the answer.

Like this:

This Pro tutorial for Bricks users shows how we can loop through the FAQs Meta Box group and inside that set up another query loop to show the selected post's data. This is one of the few ways in which this problem can be solved.

Step 1

Edit the Template that applies to your post type or a specific Page with Bricks.

Add a Section and inside its Container, add a Block and enable query loop on it.

Select your Meta Box group as the query type.

You may want to add a Heading element and set its text to the Question sub field.

Step 2

Add a Block beneath the Heading.

Enable query loop and the PHP query editor.

Paste:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 526 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Post Views Counter Query Loop in Bricks

Post Views Counter Query Loop in Bricks

How we can output the most viewed posts in your Bricks site in a query loop.
Categories:
Pro
Search Results Grouped by Post Types in Bricks

Search Results Grouped by Post Types in Bricks

Updated on 08 Oct 2024 This Pro tutorial provides the steps to arrange the search results by specified post types in a Bricks site. We…
Pro
Excluding Duplicate Posts from Query Loops in Bricks

Excluding Duplicate Posts from Query Loops in Bricks

How to ensure that posts are not duplicated when two query loops are used on the same page.
Categories:
Color Custom Field as Section Background Color on Category/Term Archives in Bricks

Color Custom Field as Section Background Color on Category/Term Archives in Bricks

How to use a color from a taxonomy term custom field for as the hero section background color on archive pages.
Categories:
Tags:
Pro
Current Single Post Reference From Inside a Bricks Query Loop

Current Single Post Reference From Inside a Bricks Query Loop

Use case: Get the single post’s custom field (like ACF Repeater or Meta Box Group) array row corresponding to the loop’s counter/index
Categories:
Pro
CPT Posts Grouped by Custom Taxonomy Terms in Bricks

CPT Posts Grouped by Custom Taxonomy Terms in Bricks

The steps to set up a Service Category terms loop with an inner Service posts loop in Bricks without writing code.
Categories:
How to Show Future Events in Bricks

How to Show Future Events in Bricks

One of the common requirements in WordPress is being able to filter the events (or could be posts of any post type) to only those…
Categories: