I am trying to return all posts that meet the following conditions:
The category must be 63
OR
the post must have a value associated with the meta key named ‘android_link’
My current argument array currently does not work because it is asking for both of these conditions to be met. Is it possible to change it so that only one of these conditions must be met to return a post?
$args = array(
'paged' => $paged,
'order' => 'DESC',
'meta_key' => 'android_link',
'post_type' => array( 'post', 'app' ),
'cat' => '63',
'meta_query' => array(
array(
'key' => 'android_link',
'compare' => 'EXISTS',
)
)
);
You can run two queries and merge the results:
You can run two queries and iterate through the results separately.
Run a simple while loop for
$cat_query
and after that run another while loop for the results of$meta_query
. This will create the same effect as you are performing OR operation on your query parameters.