13th May '25
/
1 comment

Upcoming Events with ACF Date Sub field Repeaters grouped by Month Years in Bricks

In the comments section of Upcoming Events Accordion in Bricks Grouped by 'Month Year' a member asked:

CPT: eventACF Field: event_dates (Repeater) with event_date sub field

Sample data:

After implementing the tutorial, the output with Bricks elements for the month years, event titles and dates using nested query loops:

This Pro tutorial provides the steps to

  • add a custom query type called 'Month Years' to Bricks control options
  • configure how the query runs by checking for our custom query type
  • query and retrieve all event posts
  • process each event's dates using ACF repeater fields
  • filter out past events, keeping only future dates
  • format each event's date information (day, month, year, weekday)
  • sort all events chronologically
  • group events by month and year
  • create a helper function to handle Bricks loop objects
  • build a function to retrieve specific event values (day, month, year, weekday) by Bricks ID
  • and use these to set up nested query loops for outputting the data in the desired format

Step 1

If you have not already, create the CPT and the field group.

Ensure that the return format of the date field is Ymd.

Create event posts and set all the dates on which each event is set to occur.

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

Get access to all 610 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Post Titles and Post Content Tabs in Bricks

Post Titles and Post Content Tabs in Bricks

How to set up Nestable tabs with post titles as the tab menu, and post content and/or any other post-specific data as the tab content.
Categories:
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
Configuring Image Gallery dynamic source in Bricks

Configuring Image Gallery dynamic source in Bricks

Let's say you have a custom field created with ACF Pro of the type Gallery called "Property Gallery" for posts of "Property" CPT. In the…
Pro
Query Loop in Bricks

Query Loop in Bricks

This Pro tutorial walks you through the steps to use the Query Loop feature in Bricks to display a responsive grid of posts using CSS…
Categories: