Using Orderby and meta_value_num to order numbers first then strings
-
01-11-2019 - |
Pergunta
I have a list of products, each with a price in a custom field stored as text such as "2.50" or "5.00" and I am displaying them on the page with a custom query that sorts by the price:
if(!$wp_query) {
global $wp_query;
}
$args = array(
'meta_key' => 'price',
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
query_posts( array_merge( $args , $wp_query->query ) );
This works fine for the prices, but some prices are "POA" and I would like to show them last, however the above orders in such a way that "POA" is shown first.
Is there any way to alter this, or a quick hack I could use to sort the array afterwards and put any "POA" prices last?
Nenhuma solução correta
Licenciado em: CC-BY-SA com atribuição
Não afiliado a wordpress.stackexchange