Skip to content
Advertisement

Get a product from specific product attribute term name in WooCommerce

I’m trying to create a WooCommerce shortcode to display one product with some information.

Every day there is a new product with attribute DAGAANBIEDING and value JA or NEE.

I only want to show that product with value JA.
The shortcode is working but nothing is displaying.
This is what I have:

JavaScript

But it does not show information.

Advertisement

Answer

There are some mistakes and missing things in your code. Try the following that will get the product that has pa_dagaanbieding product attribute (taxonomy) for Ja term name using a custom light SQL query:

JavaScript

Code goes in function.php file of your active child theme (or active theme). Tested and works.

USAGE: [product_ja] or echo do_shortcode('[product_ja]');

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement