WP_Query ordering numbers as letters
Question
I have some meta_fields in user profile created with ACF plugin. I am trying to run a query to get users with the following criteria:
- User must have meta_field
jogador_profissional == true
- List of users must be ordered by meta_fields
quantidade_corretas (ASC)
ANDtempo_total (DESC)
. Both are numeric values.
This is my query:
$args = array(
"fields" => "ids",
"meta_key" => "jogador_oficial",
"meta_value" => true,
"meta_query" => array(
"relation" => "AND",
"query_one" => array(
"key" => "quantidade_corretas"
),
"query_two" => array(
"key" => "tempo_total"
),
),
"orderby" => array(
"query_one" => "DESC",
"query_two" => "ASC"
),
);
$user_query = new WP_User_Query($args);
$users = $user_query->get_results();
It runs OK, but i suspect that this query is treating numeric values as string values: for example, 9 > 100
or 2 > 18
.
What am i doing wrong to make this order works in a numeric way?
Thanks.
0
advanced-custom-fields, order, plugin-development, plugins, wp-query
3 years
2020-08-27T18:10:28-05:00
2020-08-27T18:10:28-05:00 0 Answers
57 views
0
Leave an answer