Updated on 8 Nov 2024
In the comments section of Sort Posts by Meta Box Group Sub Field in Bricks tutorial, a user asked:
That worked wonderfully! Is there also a tutorial how to show past events when the event year is in a group? Also how to show only future events in this scenario? : )
Consider this scenario:
CPT: event
Field group:Meta Box Group-type field: event_group|__ Number-type subfield: event_year
Test data:

When querying the event post type, all the event posts will be output by default:

The objective is to output only the events that are in the past.
i.e., as of 2024:

or only future/upcoming events:

This is not straightforward or doable via the built-in query editor controls due to the fact that the event year post meta is inside a Meta Box group.
This Pro tutorial shows how bricks/query/result Bricks filter can be used to limit the posts output by a Posts query loop based on the value of a Meta Box group's subfield value.
Update 1: Code for the case when the subfield type is Datepicker has been added near the end.
Step 1
Set up a query loop to output Events post type.

Add Heading/Basic Text etc. elements inside the query loop-enabled Block and map them to your post data like post title and the year subfield value.
Step 2
Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:
This is a BricksLabs Pro tutorial.
For full access login below or create your BricksLabs Pro account