My custom post type order has a meta key 'status'. A post can have multiple statusses e.g. ordered, paid, completed.
I would like to query all unpaid orders. These don't have a meta key/value pair of status/paid.
I can query all paid orders with ...
array(
'key' => 'status',
'value' => 'paid',
'compare' => '=='
)
... it works
But when I try to query all unpaid orders with ...
array(
'key' => 'status',
'value' => 'paid',
'compare' => '!='
)
... WordPress also returns post which do have the status/paid pair, because they also have the status/ordered pair, which returns true.
Is there a way to fetch posts which don't have a certain meta_key / meta_value pair? Or should I write my own query using wpdb()?
Kind regards, Tom