I've added a code that allows me to sort WordPress posts through custom areas. I am trying to sort posts according to prices, but it is being sorted by first number and not worth:
$ 116.99 $ 12.95 $ 149.00 $ 15.99 < / Pre> Instead
$ 12.95 $ 15.99 $ 116.99 $ 149.00 How do I get to sort it properly?
Here's the code:
I took it from this discussion, but it was left unresolved.
If you want to do it manually (though WP_Query ), Then there may be a good treatment: $ arr = array ('$ 116.99', '$ 12.95', '$ 14 9.00', '$ 15.99'); $ Keys = array (); Forex currency ($ value as $ value) {$ key [] = float (substract ($ value, 1)); } Array_multisort ($ key, SORT_ASC, $ arr);
Comments
Post a Comment