This is a community support forum where you can ask questions and interact with other PremiumPress Customers.
I am trying to sort listings by average score (using WP-PostRating plugin and sorting feature from General Setup panel).
The score range is 0 to 10.
For some reason the sorting doesn’t recognize double digits and sees the score “10” as “1”. So the scores go like that : 9, 7.5, 6.2, 4.5, 10, 0.5, 0.
Does anyone know how to fix this error ?
iv seen this before with WordPress, it doesnt seem to like 10 (it assumes 1) have you tried 10.1?
this is happening if you are sorting custom fields using orderby=meta_value instead of orderby=meta_value_num as it is otherwise ordering numbers as alphabet (and in that case 1 and 10 would follow each other).
orderby=meta_value – ordering by alphabet
orderby=meta_value_num – numeric ordering
Here is the explanation from WordPress Codex:
‘meta_value’ – Note that a ‘meta_key=keyname’ must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect). Use ‘meta_value_num’ instead for numeric values.
‘meta_value_num’ – Order by numeric meta value (available with Version 2.8). Also note that a ‘meta_key=keyname’ must also be present in the query. This value allows for numerical sorting as noted above in ‘meta_value’.
Wide range of PremiumPress and WordPress Plugins and add-ons
PremiumPress customisation services and Website Design
Selection of PremiumPress Child Themes
I tried to put into the extra field a few variations:
None of them seem to work
I don’t think you can change the ‘orderby’ as it is hardcoded in the class_design.php.
I think Mark should add a new tick box to select whether the field is numeric or not and modify the orderby accordingly.
So Mark, can this issue be fixed?