After performing this question, I went to the next step and I wanted to sort the query results by another custom field.
I want to sort the results by a custom field that consists of a date and want to get the order from lowest to highest date
The problem is that I do not get what I ordered. I've tried several ways with no success, I googled several sites and nothing. It gives me much trouble to ask you again but I can not solve this problem.
Anyone can help me? : '(
I leave my code to see where you should embed the orderby:
$group_1 = get_posts(
array(
'posts_per_page' => 30,
'fields' => 'ids',
'meta_query' => array (
array (
'key' => 'field1',
'value' => 'data1,
),
array (
'key' => 'field2',
'value' => 'data2',
),
),
)
);
$group_2 = get_posts(
array(
'posts_per_page' => 30,
'fields' => 'ids',
'meta_query' => array (
array (
'key' => 'field1',
'value' => 'data2',
),
array (
'key' => 'field2',
'value' => 'data1',
),
),
)
);
$the_query = new WP_Query(
array(
'post__in' => array_merge( $group_1, $group_2)
)
);
Thanks!