I'm doing queries to fetch posts according to different parameters of custom fields, but I'd like the final result of the 3 queries to be displayed together.
function query() {
foreach ($values1 as $value1) {
$arrays[0][] = array(
'key' => 'my-value1',
'value' => $value1,
'compare' => 'LIKE'
);
}
$arrays[1]['relation'] = 'OR';
foreach ($values2 as $value2) {
$arrays[0][] = array(
'key' => 'my-value2',
'value' => $value2,
'compare' => 'LIKE'
);
}
if(!is_null($sofwares)) {
$arrays[2]['relation'] = 'OR';
foreach ($values3 as $value3) {
$arrays[0][] = array(
'key' => 'my-value3',
'value' => $value3,
'compare' => 'LIKE'
);
}
}
}
$args = array(
'category' => 'my-category',
'posts_per_page' => 5
);
$args['meta_query'] = query(); //chamo a função para montar
$posts = get_posts($args);
How could I make all the results of this query come together, as if they were concatenated in a single group of posts to be shown in the loop. I tried to use arrays to do multiple queries, but it is not working as expected, which would put together all the posts found in the 3 queries.