17th Jul '24
/
4 comments

Upcoming Events Accordion in Bricks Grouped by ‘Month Year’

This Pro tutorial is a variation of the previous Upcoming Events Grouped by 'Month Year' in Bricks tutorial wherein the upcoming 'month year's are shown in BricksExtras Pro Accordion with the events corresponding to that month and year with the dates based on event_date post meta value.

Given this events list:

the output after implementing the tutorial as on 17 Jul 2024 would be:

We shall loop through the events, construct an array with the necessary data, set up a custom Bricks query type for the 'month year' query loop and an inner event posts query loop that uses the outer query loop object to pull the post IDs.

Step 1

Create the CPT and corresponding date-type custom field. ACF was used in our dev site.

CPT: event

Custom field: event_dateReturn format: Ymd

Create event posts and populate the event date field for each.

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
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:
Pro
Previous Two Posts in Bricks Query Loop

Previous Two Posts in Bricks Query Loop

This Pro tutorial shows how we can modify the parameters of a Bricks query to limit the posts to the previous two whilst cycling to…
Querying Posts by Date Field to Exclude Past Events with ACPT Plugin

Querying Posts by Date Field to Exclude Past Events with ACPT Plugin

In the Bricks' Facebook group, a user asked: Meta query? What am I missing?Hi all, really need a little guidance on this one. I have…
Categories:
Pro
Modern Events Calendar in Bricks

Modern Events Calendar in Bricks

This Pro tutorial provides the steps for using Modern Events Calendar in Bricks. We shall set up the single event Bricks template with a combination…
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…