2nd Aug '24
/
4 comments

Filtering a Bricks Terms query on Term archive pages

Consider this scenario:

CPT: productTaxonomy 1: product-categoryTaxonomy 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 610 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Conditionally Hiding Bricks Filters based on Select Filter Value

Conditionally Hiding Bricks Filters based on Select Filter Value

How show or hide Bricks' filter based on the selection made by another filter.
Categories:
Tags:
Term-specific single post template in Bricks

Term-specific single post template in Bricks

Updated on 25 Jun 2025 In Reddit a user asks: Template conditional logic to exclude pages with a particular taxonomy term? I can't figure out…
Pro
ACF Relationship Select Filter in Bricks

ACF Relationship Select Filter in Bricks

In the BricksLabs Facebook group, a user asks: I'm learning about ACF relationships and attempting to output a list of posts on any given page,…
Categories:
Pro
Conditionally Excluding Elements from Bricks Editor

Conditionally Excluding Elements from Bricks Editor

In the past, we shared How to Exclude Elements from Bricks Editor. This Pro tutorial shows how specific elements can be excluded selectively based on…
Pro
x Number of Random Bricks Query Loop Items(s) to be Shown Every x Hours

x Number of Random Bricks Query Loop Items(s) to be Shown Every x Hours

Showing how to display one random row of a Meta Box group for an hour and then output another random row.
Pro
Primary Term for Posts using The SEO Framework in Bricks

Primary Term for Posts using The SEO Framework in Bricks

Updated on 18 Mar 2024 The SEO Framework is one of the better (coding-wise) SEO plugins. Like Yoast and Rank Math, it has the option…