![](https://secure.gravatar.com/avatar/19bd9b7f983e64cc237167848bad73b2?s=64&d=mm&r=g)
I have created an ajax filter and it’s not showing the results correctly.
When you click more than one checkbox it can’t find anything despite there should be something there.
I think my array is too inside itself, but can’t work out how to “unpick” it….
$exp_query[] = '';
if(!empty($experimentChoices)){
foreach($experimentChoices as $Key=>$Value){
if(count($Value)){
foreach ($Value as $Inkey => $Invalue) {
$exp_query[] = array(
'key' => $Key,
'value' => $Invalue,
'compare' => '='
);
}
}
}
}
$test = array(
'relation' => 'OR',
$exp_query,
);
$args = array(
'post_type' => 'downloads',
'meta_query' => array(
'relation' => 'AND',
$test,
),
);
So it outputs as;
FOREACH (Broken)
Array ( [relation] => OR [0] => Array ( [0] => [1] => Array ( [key] => experiment_type [value] => abuse-dependence [compare] => = ) [2] => Array ( [key] => experiment_type [value] => diabetes [compare] => = ) ) )
WRITTEN CODE (Working)
Array ( [relation] => OR [0] => Array ( [key] => experiment_type [value] => abuse-dependence [compare] => = ) [1] => Array ( [key] => experiment_type [value] => diabetes [compare] => = )
Any help would be great thanks.