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..

bricks/posts/merge_query Explained

bricks/posts/merge_query Explained

This short article provides details on Bricks' bricks/posts/merge_query filter. On pages rendered by an archive or search template, secondary queries like the ones used for…
Categories:
Tags:
Pro
Limit the Number of Posts in a Bricks Query Loop of Relationship Type

Limit the Number of Posts in a Bricks Query Loop of Relationship Type

Updated on 12 Dec 2023 Bricks Query Loop popup does not have a control for setting the number of posts to be output when the…
How to create filters with IsotopeJS in Bricks (Part 1)

How to create filters with IsotopeJS in Bricks (Part 1)

This tutorial series will explore the IsotopeJS library's features inside the Bricks ecosystem.
Categories: