Scenario
I am working on a project where courses are listed for the year. I created a course schedule post type and then added a cloneable group for the classes. The classes include a start date and a graduation date.
BricksExtras Dynamic Table
Since the class list is fairly short— unlikely to ever exceed 20 in a year — I opted to use the BrickExtra dynamic table. This gave me the ability to output the table and assign the heading titles with the need for search and sorting.

Filtering the Cloneable Group
The challenge was only showing the courses based on future dates and not all the dates. Not only would this change automatically over time, but it could also reduce the frustration for potential students only wanting to see upcoming classes.
Turning to one of my favorite resources — BricksLabs — I found an example that did precisely what I needed with one slight adjustment. The original example was set to look for things starting today (===), and I needed things beginning in the future, including today (>=). This is a pro tutorial, so you must purchase access.
add_filter( 'bricks/query/run', function( $results, $query_obj ) {
if ( $query_obj->element_id !== 'queryid' ) return $results;
//Replace queryid the Bricks ID of your query loop element.
// return only the results that have date_khpbe7p5pn Meta Box sub field value set to today's date
$filtered_results = array_filter( $results, function( $result ) {
return $result['date_khpbe7p5pn'] === date( 'Y-m-d' );
} );
return $filtered_results;
}, 30, 2);
Leave a Reply