I currently have defined a few custom post types.
- a product category size
- a product category
- a product.
Inside my product, I hold and save meta data on a dropdown list of product categories. So for example,
A ball, is in category of toy.
Inside my product category, I hold meta data on product size. This is via a custom dropdown list of product category sizes.
So for example, toys come in small, medium or large.
My question, is how to create a WP_Query to return products, in a particular category size.
e.g. A list of small toys.
I need to create a function that takes a product id as the first argument, and product_category_size ID as the second argument, and returns the list.
Any ideas how to expand upon this below to first go into product category, and then go into product category size? Or am I looking at a completely custom SQL query?
Worth noting that I prefer this more 'normalised' approach, rather than storing category size at the product level as well.
$args = array( 'meta_query'=> array( array( 'key'=>'_productcategory', 'value'=> $id, 'compare' => '=' ) ), 'post_type'=>'product', 'post_status' => 'publish' );