Category Posts Accordion in Bricks

This Pro tutorial provides the steps to set up a dynamic accordion of posts grouped by their categories based on the previous Posts Grouped by Categories in Bricks tutorial.

We are going to set up two query loops inside an Accordion (Nestable) Bricks element - one inside the other. The outer one loops through terms and the inner one through posts. We shall then write a bit of code using the bricks/posts/query_vars filter hook to restrict or limit the posts in the inner loop to only those assigned to the outer loop's current category.

Remember that this can be applied to posts of any post type grouped by a corresponding taxonomy (built-in or custom) and is not limited to just posts and categories.

Step 1

Copy and paste the entire Section from our test site in your Page/template (when editing with Bricks) using the Section's JSON from the link below.

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 525 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Nested Meta Box Query Loop Inside a CPT Query Loop in Bricks

Nested Meta Box Query Loop Inside a CPT Query Loop in Bricks

This Pro tutorial provides the steps for setting up a cloneable Meta Box group query inside a CPT query in Bricks. Scenario: CPT: course Meta…
Categories:
Pro
Parent Query Loop Object – Traversing Nested Query Loops Up in Bricks

Parent Query Loop Object – Traversing Nested Query Loops Up in Bricks

Bricks enables us to build nested query levels of unlimited levels. Here are a couple of examples: Sometimes, you might want to obtain the parent…
Categories:
Pro
6 Random Featured Posts in Alphabetical Order in Bricks

6 Random Featured Posts in Alphabetical Order in Bricks

How to output x number of random posts with a specific meta value set, in Alphabetical order.
Categories:
Pro
Dynamic Accordion in WordPress using Meta Box and Alpine.js

Dynamic Accordion in WordPress using Meta Box and Alpine.js

This Pro tutorial provides the steps to implement an accordion using Alpine.js in WordPress that pulls the values of sub fields of a Meta Box…
Pro
Accordion Grid Query Loop in Bricks

Accordion Grid Query Loop in Bricks

How to set up a accordion in Bricks such that the "titles" are arranged in a grid with the full width content opening below.
Categories:
Bricks single mode – Limiting the number of posts to 1 in the editor

Bricks single mode – Limiting the number of posts to 1 in the editor

Creating a "Single Mode" for Bricks query loops to make sure only one post is rendered in the builder.
Pro
Post Views Counter Query Loop in Bricks

Post Views Counter Query Loop in Bricks

How we can output the most viewed posts in your Bricks site in a query loop.
Categories: