1st Jul '24
/
4 comments

Upcoming Events Grouped by ‘Month Year’ in Bricks

Updated on 5 Dec 2024

In the comments section of Events grouped by months within years based on event date custom field value tutorial, a member asked:

... A good update for this would be a single loop of just MONTH YEAR with the events under each Month and Year, rather than YEAR, then MONTh then events.

This Pro tutorial is another example of custom advanced Bricks query loop types for showing future posts of event CPT based on a date custom field using three nested query loops.

The Heading element's text is dynamic and automatically pulls data from the Event Year and Event Month query loop objects.

Similarly, the Post Loop pulls the year and month from the parent queries, passes them to a custom function which returns the IDs of posts from that year and and that month.

Events list:

Output on the front end after implementing the tutorial:

Step 1

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

Related Tutorials..

Pro
ACF Taxonomy Field Value in Single Posts

ACF Taxonomy Field Value in Single Posts

Consider this scenario: CPT: Movie Movie CPT Taxonomy: Movie Genre Movie Genre Taxonomy's field: Genre Color Each movie will have only genre set. The requirement…
Categories:
Tags:
Pro
Child Posts Section in Bricks

Child Posts Section in Bricks

This Pro tutorial provides the steps to limit the posts (can be of any post type) output by Bricks' query loop to children of the…
Categories:
Pro
Ordering Posts by Terms in Bricks

Ordering Posts by Terms in Bricks

How to output upcoming events at the top and past events below in a single query loop in Bricks.
Categories:
Pro
Custom Nested Queries in Bricks

Custom Nested Queries in Bricks

In most of the previous tutorials covering nested query loops in Bricks on this site, we accessed the parent query's looping object in the inner…
Categories:
Pro
ACPT Gallery Field Query Loop in Bricks

ACPT Gallery Field Query Loop in Bricks

How we can output images from ACPT‘s Gallery field for posts as a grid using a query loop.
Categories: