i'm trying to order my results with query_posts function by a custom field.
Here is my edited query_posts() function:
query_posts( "post_type=produkte&".$query_string."&orderby=Price&order=DESC" );
The Price looks like that {Euro}.{Cent} for example 1.49.
And the query_posts() function orders it not right. The result is ordered like that:
0.49, 1.99, 0.99
What is going wrong?
Thanks in Advance!
If you want to show the fields inside the post, you have to place the code inside the loop of "single. php", supposing you are using the standard post type. This code retrive the field only, it won't show anything, it's used to store the value in a variable: get_field('field-name');
Simply create a new post or edit an existing one. Go to the custom fields meta box and select your custom field from the drop-down menu and enter its value. Click on the 'Add Custom Field' button to save your changes and then publish or update your post.
You may try this (hopefully it'll work/found online)
query_posts( "post_type=produkte&".$query_string."&meta_key=Price&orderby=meta_value_num&order=DESC" );
Another answer on SO.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With