CPT Posts Grouped by Custom Taxonomy Terms in Bricks

A user asked via email:

I need some help with querying custom taxonomies in Bricks and I hope you could help me with that.

I have CPT created with Metabox called Services. I also created a custom taxonomy called Service Category.

I want to create a query that will first show all of the terms, and then inside this query there should be one more query, that will be querying through the services from this particular taxonomy.

Everything is working apart from the second inner query, I cannot get it to filter and show only services that are part of this current particular query, it is always showing all services, and I do not know how to solve this problem.

To give you some more context, here's the link showcasing how it should look like, I'm currently building it as a static page, as I did not find any other solution:

This Pro tutorial provides the steps to set up an outer Service Category terms loop and an inner Service posts loop in Bricks without writing a single line of code.

This works with posts of any post type and terms of any taxonomy incl. categories.

Step 1

Register your CPT and the associated custom taxonomy using Meta Box or ACF or CPT UI or otherwise.

CPT:

Custom Taxonomy:

Resave permalinks.

Step 2

Add posts of your CPT and select the corresponding terms for each.

Step 3

Create a template called say "Services" of the type Archive.

Edit it with Bricks.

Add a template condition to make it apply to your CPT archive page.

Copy the below JSON code and paste to import a Section having this structure:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 524 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

How to Show Future Events in Bricks

How to Show Future Events in Bricks

One of the common requirements in WordPress is being able to filter the events (or could be posts of any post type) to only those…
Categories:
Pro
Query Loop in Bricks

Query Loop in Bricks

This Pro tutorial walks you through the steps to use the Query Loop feature in Bricks to display a responsive grid of posts using CSS…
Categories:
Pro
Top-level Pages and Children Bricks Query Loop

Top-level Pages and Children Bricks Query Loop

This Pro tutorial for Bricks users can be considered Part 2 or a variation of the earlier Bricks Query Loop for Top-level Parent Pages with…
Categories:
Pro
Dynamic Posts Lightbox in Bricks using GLightbox

Dynamic Posts Lightbox in Bricks using GLightbox

Steps to set create a dynamic lightbox with content from the post inside of the query loop.
Categories:
Posts Related by Current Post’s Terms in Bricks

Posts Related by Current Post’s Terms in Bricks

Showing other posts assigned to the same categories/tags/custom taxonomy terms as the current post.
Categories:
Pro
Non-empty events sorted by event date and other posts below in Bricks

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…
Categories:
Pro
Posts from Random Categories in Bricks

Posts from Random Categories in Bricks

Updated on 31 Jul 2023 In BricksLabs Facebook group a user asked: How would you query 3 WordPress posts from 3 different categories with Brick…