Product Attribute based Related Products Bricks Query Loop

This Pro tutorial provides the steps to output products related by value of attribute(s) for the current product on single WooCommerce product pages in Bricks.

Let's consider a product that has Gray color.

After implementing this tutorial, viewing this product on the front end will show:

(ignore the array data near the end)

where "T-Shirt with Logo" is the only other product in the site that also has color attribute with Gray value.

Another product that has multiple attribute values and hence the related products in this case are all the products that are blue or green or red:

Single Tutorial Purchase Option

Lifetime access to this single tutorial can be purchased for $39 here.

Step 1

Implement the Products in the Same Product Categories as the Current Product in Bricks tutorial.

Step 2

For the query loop-enabled Block, turn off PHP query.

Ensure that Post type is Products and Posts per page is a large number that is higher than the possible number of matching products any given time, now or in the future.

Re-enable the PHP query.

Replace the query loop's PHP query with:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Instant access to 390+ Bricks code tutorials with BricksLabs Pro