I'm cracking my head with a problem I'm having with Wordpress.
I am using the meta_value_num
sort order from a meta_key
that goes the value of some properties (the value is placed without decimals, eg: 100000 (100 thousand)). However, when ordered in this way, it is not in the desired order, eg 100000, 190000, 235000, 1000000, etc.
The following is 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 searches, I found an article talking about using a SQL query for this something like ORDER BY ABS
, but my SQL knowledge is pretty basic.