0
I’m cracking my head with a problem I’m having with Wordpress.
I’m using the ordination meta_value_num
to sort from a meta_key
that goes the value of some properties (the value is placed without decimal places, ex: 100000 (100 thousand)). However, when ordered in this way, it is not in the desired order, e.g.: 100000, 190000, 235000, 1000000, etc.
Follow the code below:
$orderby = array('post_type' =>
'imovel', 'posts_per_page' => 12,
'paged' => get_query_var('page'),
'meta_key' =>
'valor_do_imovel',
'orderby' => 'meta_value_num',
'order' => 'DESC'
);
$args = array_merge( $wp_query->query_vars, $orderby );
query_posts( $args );
During the searches, I found an article talking about using an SQL query for something like ORDER BY ABS
, but my knowledge about SQL is very basic.
Do you want the order to be for the value of the property? From the smallest to the largest?
– Lollipop