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

Get access to all 526 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
How to Modify Products Element Query in Bricks to Output Child Products

How to Modify Products Element Query in Bricks to Output Child Products

This Pro tutorial provides the steps to limit WooCommerce products output by Bricks' Products element on single product pages to only the children of the…
How to add a “Sold Out” badge for out of stock products in Bricks

How to add a “Sold Out” badge for out of stock products in Bricks

Looking to add a "Sold Out" badge for products in the Shop page for WooCommerce products that are out of stock when using Bricks' Products…
Pro
Out of Stock Ribbon for WooCommerce Products in Bricks

Out of Stock Ribbon for WooCommerce Products in Bricks

Show an “OUT OF STOCK” ribbon for WooCommerce products that are output via the Products element on listing pages.
Categories:
Pro
[WooCommerce] Sale price dates in Bricks

[WooCommerce] Sale price dates in Bricks

Outputting start and end sale price dates (if set) for WooCommerce products.
Categories: