i heve the following loop:
$argsvs = array(
'post_type' => 'imovel-para-venda',
'meta_key' => 'wpcf-imovel-preco',
'posts_per_page' => 0,
'oderby' => 'meta_value',
'order' => 'DESC'
);
$loop = new WP_Query( $argsvs );
while ( $loop->have_posts() ) : $loop->the_post();
…..
well, the thing is that it isnt working! The meta_key ‘wpfc-imovel-preco’ is a custom field creating using the plugin Types. It is filled with numbers and text sometimes. Well, the code above simply doesnt sort anything 🙁 Any ideas?
The problem is that you have
oderbyinstead oforderby– you missed therin there.I tested your code and it’s otherwise working. There is only one thing to keep in mind though – number meta values will be ordered separately from string meta values, here is an example:
I have 5 pages with the following values for their custom fields:
abc,acb,dcb,3,5. When I order them in ascending fashion, they are ordered as follows:35abcacbdcbIf you switch back to descending, you get:
dcbacbabc53