19th Mar '24
/
6 comments

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 612 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Events grouped by Event Date custom field in Bricks

Events grouped by Event Date custom field in Bricks

This Pro tutorial for Bricks users provides the steps to output posts of an event custom post type dynamically grouped by the value of their…
Categories:
Pro
Nav Menus Custom Query Types in Bricks

Nav Menus Custom Query Types in Bricks

Updated on 21 Aug 2024 This Pro tutorial shows how custom query types for each navigation menu can be generated in Bricks. This enables us…
Pro
Posts Grouped by Taxonomy Terms in Bricks using BricksExtras’ Dynamic Table and Pro Tabs

Posts Grouped by Taxonomy Terms in Bricks using BricksExtras’ Dynamic Table and Pro Tabs

How to output any post type, with the taxonomy terms as Tab titles and posts inside tables with sortable columns.
Pro
Adding active class to the current term/post in a Bricks query loop on Term archives/single posts

Adding active class to the current term/post in a Bricks query loop on Term archives/single posts

Updated on 29 Feb 2024 In the Sibling Terms Bricks Query Loop tutorial, a member asked: How can I set the class "active" to the…
Categories:
Using WP Grid Builder Facets with Bricks’ Query Loop

Using WP Grid Builder Facets with Bricks’ Query Loop

Update: This tutorial was written before WPGB had a Bricks add-on. Now, it is advisable to use that add-on instead. Get it from here. Updated…
Categories:
Pro
Post-specific ACF Repeater Galleries as Sliders in Bricks

Post-specific ACF Repeater Galleries as Sliders in Bricks

How to output ACF Repeater field rows with the images of the Gallery-type sub field as a slider.