Jings
Jings

Reputation: 8690

Wordpress query_posts Order By Custom Field

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!

Upvotes: 6

Views: 10158

Answers (1)

The Alpha
The Alpha

Reputation: 146191

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.

Upvotes: 9

Related Questions