Posts Ordered By a Date Field in Bricks

The Query interface available in the Posts element and the Query Loop feature of Bricks enables us to order items of any post type by the value of a date-type of custom field.

Here’s a sample screenshot of this out-of-the-box option:

Here we are telling Bricks to ask WordPress to fetch the latest 10 (this is the number set at Settings → Reading → Blog pages show at most) posts of a workshop Custom Post Type with the items (posts) ordered in ascending order of the value of a workshop_date custom field that is of Date-type.

Note that this will output only the posts that have the custom field populated.

Instant access to 390+ Bricks code tutorials with BricksLabs Pro

Leave the first comment