Filtering a Bricks Terms query on Term archive pages

Consider this scenario:

CPT: product
Taxonomy 1: product-category
Taxonomy 2: product-type

Requirement: On product category archives, show product type names but only those that the current product category (posts assigned to the current product category) has.

This Pro tutorial shows how this can be done using bricks/terms/query_vars Bricks filter.

Step 1

Edit your product category archive template with Bricks.

Set up a Terms query loop and select the Product Type taxonomy.

This will show all the product types.

In the next step, we shall restrict these to only those that the current product category products have.

Step 2

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

Get access to all 525 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
How to Inject a Different Type of Post in Bricks Query Loop

How to Inject a Different Type of Post in Bricks Query Loop

Updated on 26 Aug 2024 A user asks: Hello, I'd like to inject a CPT post card inside of a Bricks query loop of a different CPT…