Posts Grouped by Years in Bricks

This Pro tutorial provides the steps to output posts that show the most recent year in which the last post was published, then all the posts that were published in that year and continue with rest of the years in descending order in Bricks.

We shall create a custom query type called "Published Years", apply it on a query loop and place another query loop inside for showing posts that were published in the year of the parent loop iteration.

This solution gives full control to visually build the display of years (headings) and what appears for each post (date, month and linked post title in this example) using Bricks elements.

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

Instant access to 390+ Bricks code tutorials with BricksLabs Pro