sorting - Wordpress: Sort Order by Custom Field Numerically -


How can I sort custom field data numerically that is stored as string I I will not change it in database can.

  query_posts ($ query_string. 'And orderbay = meta_qua and meta_key = price and order = dex');  

This is what I am using but it is classifying it as a string because it is also stored as a string.

Can anyone tell me how can I change it numerically without changing the database?

Thanks in advance.

Majhi

You can do this string meta data with a race:

$ codestr = "SELECT wposts. $ Wpdb- & amp; posts; posts wposts, $ wpdb-> postmeta Wpostmeta WHERE wposts.ID = wpostmeta.post_id and wpostmeta.meta_key = 'Price' and wposts.post_type = 'post' order by ABS (wpostmeta.meta_value) DESC ";

If your meta value includes a dollar sign ($ 123.45), then you can cancel it by ORDER:

  ORDER BY ABS (SUBSTRING (wpostmeta) .meta_value, 2)) DESC  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -