#10649 closed enhancement (fixed)
Meta_key sort for numeric values / Natural Sort Order
Reported by: | stencil | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | 2.8.4 |
Component: | Query | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
When trying to sort posts by meta_key with numeric values the order is not "natural".
eg: 1, 10, 2, 3, 4, 5, 6, 7, 8, 9
This should be
eg: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
I have attached a simple addition to wp-includes/query.php which allows for this type of sorting.
Query use: orderby=meta_value_num
Attachments (3)
Change History (10)
#1
@
15 years ago
- Milestone changed from Future Release to 2.9.3
- Priority changed from normal to high
Any chance of pushing this fix please? It keeps annoying me each time I upgrade WP.
or is there a blocking issue?
#2
@
15 years ago
- Keywords dev-feedback has-patch added
- Milestone changed from 2.9.3 to 3.0
Moving to 3.0, as 2.9 is not for new enhancements/feature requests.
Perhaps another dev who's more database savy than I can comment on any particular issues which this might cause? Whilst i see none, Would be handy to know that for sure.
#3
@
15 years ago
I think this is really a bug, simply because sorting posts via a numerical meta_key fails to work when values are > 9.
The addition of meta_value_num would be a new feature, yes, but not really required just to fix this bug (which is in the DB query).
#4
@
15 years ago
- Keywords commit added; dev-feedback removed
- Priority changed from high to normal
Patch looks good.
Addition of meta_value_num