0

How can I use a meta query like this:

>>>>>> KEY_X Conditional IS ABSOLUTELY REQUIRED <<<<<<<<<< 
            array(
                'key' => 'Key_X',
                'value' => 'Value_for_X'

            ),
>>>>>> KEY_Y **OR** KEY_Z ARE REQUIRED  / AT LEAST ONE <<<<<<<<<<
            array(
                'key' => 'Key_Y',
                'value' => 'Value_for_X'
            ),
            array(
                'key' => 'Key_Z',
                'value' => 'Value_for_Z'
            )

So the first one is an absolute must, and then one or the other is required (at least one).

Thank you so much!

Ciprian

0

1 Answer 1

1

Short answer: You can't do that.

The query system is a simplified version, by design. It cannot do combinations of ANDs and ORs across keys like that.

If you want to do that, you'll need to write your own SQL in some manner. The meta_query is not capable of that complex of a query.

1
  • Thank you for the answer! Can you point me in the right direction on how to do a custom SQL query.
    – Ciprian
    Oct 25, 2013 at 22:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.