A meta_value
field is always text; the fieldtype in the database structure is longtext
, so unless you’re explicitly typecasting when retrieving it (i.e. $price = (float)$custom['price'][0];
– which won’t help with ordering in the first place), you can’t ‘adjust’ the custom field data – it’s always stored as text.
Having said that, you should simply remove the initial meta_value
in your orderby
argument:
$args['meta_key'] = 'price';
$args['orderby'] = 'meta_value_num';
$args['order'] = 'ASC';
Having used this exact argument set myself just yesterday, it works perfectly.