Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I currently have defined a few custom post types.

  1. a product category size
  2. a product category
  3. 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'
        );
share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.