12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Feb 16, 2022

How to show linked products on product category archives using ACF in Oxygen

Sridhar Katakam

In the WPDevDesign Facebook group a user asked:

A client wants to show specific woocommerce products attached to the specific product category archive in the sidebar,for example,there is a product category as CAR SIDE MIRRORS,and he have some products as services that provide a full installation, finish, only mirror change etc,Now he wants to show these services on category archive.The client have ACF Pro, I'm thinking about creating a relationship field to product category and to output it on frontend.BUT I'm an ACF Beginner... I can't figure it out.NOTE : I'm using Oxygen Builder.

This members-only tutorial provides the steps to add a Taxonomy-type of custom field for product post type, select a product category for a product via the custom field, and show that and other products that also have the same product_cat when viewing any product category archive page.

The requirement can be summarized like this:

Get all products for whom meta value of product_category (name of the custom field) is set to the term ID of the current archive being viewed.

Step 1

Install and activate ACF.

Create a field group called say, "Product Fields" having a Taxonomy-type of custom field having a lable of say, "Product Category".

Change the Appearance to Select so that single value can only be selected for the product entries.

Leave the default Return Value of Term ID.

Set the group to appear on Product CPT.

Step 2

Edit your products and populate the custom field by selecting the corresponding category from the dropdown.

Step 3

Edit (create one if not present already) the Template that applies to product category archives with Oxygen.

Add a Easy Posts or Repeater where you would like to show the products for which the current category has been selected.

Change the query type to Advanced and set it up like so:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $599 one-time).

Already a member? Log in below or here.

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-downarrow-right