I’m trying to do some filtering for some posts in WP_Query
, but I can’t seem to get the right condition. Basically what I wanna do, is get posts that have the custom field event_data
(sorted by this field) and among those posts to select only those who have one of these other fields filled in event_doc1
, event_doc2
, event_doc3
, main_doc
.
The code is below.
$metaCondition = array(
'relation' => 'OR',
array(
'key' => 'main_doc',
'value' => 0,
'compare' => '!=',
'type' => 'NUMBER'
),
array(
'key' => 'event_doc1',
'value' => 0,
'compare' => '!=',
'type' => 'NUMBER'
),
array(
'key' => 'event_doc2',
'value' => 0,
'compare' => '!=',
'type' => 'NUMBER'
),
array(
'key' => 'event_doc3',
'value' => 0,
'compare' => '!=',
'type' => 'NUMBER'
)
);
$query = array(
'numberposts' => 4,
'orderby' => 'meta_value',
'meta_key' => 'event_data',
'order' => 'ASC',
'meta_query' => $metaCondition
);
Thanks in advance to everone!