I have searched high and low for this but I cant seem to locate anything.
I am trying to filter some results and when I make an args array like this and pass it to query_posts I noticed that the generated SQL uses AND instead of OR for the 'class_1_days' value. I would like to make than an OR. How would I go about doing this? (I am using LIKE there as the data is serialized, otherwise I would have tried an "IN" and pass an array. What is the proper way to go about this?
$args = array(
'taxonomy' => 'courses',
'term' => 'drawing',
'post_type' => 'school',
'paged' => $paged,
'meta_query' =>
#$checkbox_array,
array(
array(
'key' => 'instructor',
'value' => '1128',
'compare' => 'LIKE',
),
array(
'key' => 'class_1_days',
'value' => 'Friday',
'compare' => 'LIKE',
),
array(
'key' => 'class_1_days',
'value' => 'Saturday',
'compare' => 'LIKE',
),
)
);
This is the relevant SQL that is being generated where I noticed the AND
[138] => Array
(
[0] => SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)
INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id)
INNER JOIN wp_postmeta AS mt2 ON (wp_posts.ID = mt2.post_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (18) ) AND wp_posts.post_type = 'school' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND ( (wp_postmeta.meta_key = 'instructor' AND CAST(wp_postmeta.meta_value AS CHAR) LIKE '%1128%')
AND (mt1.meta_key = 'class_1_days' AND CAST(mt1.meta_value AS CHAR) LIKE '%Friday%')
AND (mt2.meta_key = 'class_1_days' AND CAST(mt2.meta_value AS CHAR) LIKE '%Saturday%') ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 5