[wp-hackers] Sorting on Custom Fields

Kevin Newman CaptainN at unFocus.com
Tue Jul 13 23:00:43 UTC 2010


  On 7/13/10 4:54 PM, Ken wrote:
>>> erminology) these fields (as well as search on them).
>>>
>>> There is a plugin called wp-smart-sort which seems to do sorting by 
>>> looping through the results of a custom query and storing the post 
>>> data in an array and ordering that in memory ("seems to", because I 
>>> didn't take the code apart all that thoroughly).
>>>
>>> I'm leaning toward using a custom table, because sorting in server 
>>> memory seems inefficient, and I have a crazy number of values 
>>> anyway. But serializing those in a single custom field, doesn't seem 
>>> crazy either.
>>>
>>> Anyway, I'd love to see opinions on this. :-)
>>>
>>
>> Do we not have support for query_posts / WP_Query to do this already?
>>
>> You can order by meta_keys and meta_values from what I recall.
>>
>
> http://wplookup.com is helpful for this.
>
> You may be looking for this (Codex should be improved soon do to the 
> 3.org)
> http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query
> http://codex.wordpress.org/Function_Reference/query_posts
> http://codex.wordpress.org/Function_Reference/get_posts
> http://codex.wordpress.org/Function_Reference/add_meta_box
> http://codex.wordpress.org/Custom_Fields 

Oh! I didn't even look at that yet. Time to dig in!

Thanks guys!

Kevin N.




More information about the wp-hackers mailing list