This site is getting rebuilt from scratch. Watch this space.

Group Bricks posts by category (loop)

If you’re using Bricks Builder and you’ve ever tried to group posts by category inside a loop, you’ve probably hit the same wall I did.

You can query posts just fine.
You can filter by category just fine.
But grouping them – category heading once, then the related posts underneath – isn’t obvious at all.

This post walks through a clean, reliable way to do it.

No hacks. No plugins. Just working logic.

Final result

The Bricks setup (high level)

Here’s the approach used:

1. Outer loop: Categories

  • Query type: Terms
  • Taxonomy: category
  • Optional: exclude empty categories if you want a tighter page

This loop is responsible for:

  • the category heading
  • the container that holds that category’s posts

2. Inner loop: Posts

Inside the category loop, add another query loop:

  • Query type: Posts
  • Tax query:
    • Taxonomy: category
    • Field: term_id
    • Value: dynamic → current term ID

Now each category only pulls in its own posts.

Clean separation. No duplication.

Back to blog