• Hello,

    I have digged the hole day long for being able to sort custom fields with only the help of the query_posts() attribute.

    I find it hard to implement the technique described here: http://ww.wp.xz.cn/support/topic/sort-posts-by-custom-field-numeric-value?replies=12

    My “problem” is that I have both numbers and letters in the custom_fields like the following example:

    meta_key meta_value
    cow_type belgienblue
    cow_legs 40
    cow_nose 1
    cow_type Awsome-Cow
    cow_legs 7
    cow_nose 2

    I want to be able to sort by all the meta keys (cow_type, cow_legs, cow_nose). With all I mean not all at the same time, but when I click a link for cow_type, cow_type should be ordered and cow_legs and cow_nose is then independent. As you can se when sorting cow_legs, it is a number and when sorting on cow_type it is letters.

    So here I’m stuck using the technique http://ww.wp.xz.cn/support/topic/sort-posts-by-custom-field-numeric-value?replies=12

    Because then the SQL-question should look different depending if it is a letter or number based custom_fields.

    So my question is, do I have any chance to solwe this with a query_posts() statement or is this impossible and I most use the technique linked above?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Sort custom fields’ is closed to new replies.