I got this wordpress array and need a while loop inside for every 'AND' relation:
$query_args = array(
'post_type' => 'post',
'post_status' => 'publish',
'meta_query' => array(
'relation' => 'OR',
array(
'relation' => 'AND',
array(
'key' => 'foo_0_start',
'compare' => '>=',
'value' => '$start'
),
array(
'key' => 'foo_0_end',
'compare' => '<=',
'value' => '$end'
)
),
array(
'relation' => 'AND',
array(
'key' => 'foo_1_start',
'compare' => '>=',
'value' => '$start'
),
array(
'key' => 'foo_1_end',
'compare' => '<=',
'value' => '$end'
)
)
)
);
I was searching for hours and tried to build a function without success. How can I accomplish this issue? And what happens with the "'relation' => 'OR',"?
$query_args = array(
'post_type' => 'post',
'post_status' => 'publish',
'meta_query' => array()
);
$i = 1;
while ($i<=5;) :
$i++
$query_args['meta_query'][] = array (
'relation' => 'AND',
array(
'key' => 'foo_$i_start',
'compare' => '>=',
'value' => '$start'
),
array(
'key' => 'foo_$i_end',
'compare' => '<=',
'value' => '$end'
)
);
endwhile;
Help would be highly appreciated.
ok. Found the solution: