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 632 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Bricks Query Loop – How to Insert Elements After Every Nth Post

Bricks Query Loop – How to Insert Elements After Every Nth Post

Update: Follow this tutorial instead. This Pro tutorial provides the steps to output element(s) in a Bricks' query loop after every nth post. Use case:…
Categories:
Pro
Masonry for Query Loop in Bricks

Masonry for Query Loop in Bricks

If you are looking to implement masonry with a 'view more' button i.e., click-type of infinite scroll follow this tutorial instead. Updated on 15 Mar…
Categories:
Bricks Query Loop – Posts Authored by Logged in User

Bricks Query Loop – Posts Authored by Logged in User

How to display only the posts authored by the currently logged-in user in a query loop.
Categories:
Pro
Per-Category Load More with Post Count in Bricks Builder Nested Query Loops

Per-Category Load More with Post Count in Bricks Builder Nested Query Loops

In the BricksLabs group, a user asks: Hi everyone! I'm working on a website where I need to list a large number of products on…
Using WP Grid Builder Facets with Bricks’ Query Loop

Using WP Grid Builder Facets with Bricks’ Query Loop

Update: This tutorial was written before WPGB had a Bricks add-on. Now, it is advisable to use that add-on instead. Get it from here. Updated…
Categories: