Skip to content
Advertisement

WooCommerce Filter products with ACF and Product Category

I am using WooCommerce to display a product loop and have built out a filter for the same loop. The filter uses acf meta which the values are pulled directly from the query string. The meta_query is working as expected, however the tax_query seems to be not ineffective. I need some assistance as to why my tax_query is not producing the correct results.

JavaScript

a var_dump of $tax_query results in:

JavaScript

Advertisement

Answer

I wanna try to be clear as possible here:

You are gonna set your $meta_query_args and your $tax_query_args in different keys:

Your meta_query will be set like:

JavaScript

Your tax_query args will be set like: (Modify accordingly to your needs.)

JavaScript

your final query should look like this more or less for the meta_query and tax_query keys:

JavaScript

PD: I have not tested it, but should be good for what you want to achieve.

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