I have 2 custom fields that I would like to do a meta query on for a custom post type:
start_date
status
The outcome that I am looking for is
(start_date >= 1332115200 AND status = 1) OR (status = 2)
Is this possible to do with WP_Query?
|
I have 2 custom fields that I would like to do a meta query on for a custom post type:
The outcome that I am looking for is
Is this possible to do with WP_Query? |
|||
|
|
|
No, There are a couple of ways to work around this limitation.
Note that either way, this query is not going to be all that fast, since it requires some loose type casting on unindexed |
|||||||||
|
|
I think your answer is on this page, read the section, Order & Order By Paramaters. In simple terms, ordering by meta_value means your query will have something like this in it
... but to do something like the example you gave is a bit more tricky though I think you'll find it's actually explained under the heading "Multiple Custom Field Handling:". Read that in conjunction with the second part of "Custom Field Parameters" and you should eventually get it. Pay attention to the arrays. I think you should end up with 3 nested arrays in your case. |
|||
|
|