14th Jan '24
/
0 comments

Non-empty events sorted by event date and other posts below in Bricks

Updated on 15 Jan 2024

Consider a scenario where you are showing posts from multiple post types namely post, event and game in a single query.

Also, events have an event_date custom field created using ACF.

By default, all the posts are ordered by date published in descending order.

Ex.:

Notice how there's no event date set for Event 6.

Requirement: Exclude the empty events and order the non-empty events by event date at the top, with the rest of the items of other post types below.

Like this:

This Pro tutorial shows how advanced meta queries using named clauses can be written and used in Bricks.

Here's how

Select the element on which query loop is enabled.

Select the post types in the query settings.

Turn on "Query editor (PHP)".

Paste:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 633 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
ACF User Field Bricks PHP Query

ACF User Field Bricks PHP Query

In the Bricks Facebook group a user asks: my end goal was to create a set of cards that would display the Users that are…
Categories:
Pro
Events grouped by months within years based on event date custom field value

Events grouped by months within years based on event date custom field value

How to output events grouped by years and months using three nested query loops in Bricks.
Categories:
Pro
ACF Relationship: Show all other events related to the artists of the current event

ACF Relationship: Show all other events related to the artists of the current event

How all other events related to the artists of the current event can be output in a Bricks query loop.
Categories:
Pro
CMB2 Repeatable Group Bricks Query Loop

CMB2 Repeatable Group Bricks Query Loop

This Pro tutorial provides the steps to create a custom query loop type for outputting the subfield values of a Group field (repeatable) when using…
Auto Responsive Grids in Bricks

Auto Responsive Grids in Bricks

This tutorial provides the CSS that can be pasted for automatic responsive grids in Bricks Builder. Posts element Each post will get a right padding…
Pro
Dynamic Horizontal Posts Accordion in Bricks

Dynamic Horizontal Posts Accordion in Bricks

Update on 8 Sep 2024: You may want to follow the newer version that considers accessibility. Looking to make a Horizontal Image Accordion dynamic? This…