[wp-hackers] Sorting Meta Fields

Dave Hendler sollaires at gmail.com
Thu Dec 15 17:15:22 GMT 2005


On 12/15/05, Scott Merrill <skippy at skippy.net> wrote:
> Dave Hendler wrote:
> > Basically, if
> > the orderby parameter sent to query_posts() is not in the allowed
> > array (author,date,category,title), I perform an additional join to
> > the postmeta table and mess about a little bit to get things working.
>
> It might be better to make an explicit query parameter for postmeta, so
> that you can order the results by meta value _and_ order them by
> author/date/cat/title.
>

The orderby param actually works this way now.  If you use a string
like "orderby=category date", it's exploding on the space and doing
multiple ORDER BYs.  My code has this working as well for meta data
fields (so "orderby=my_field date" works).  However, it doesn't do the
same thing for the sort direction.  Should I use a seperate query
param or build in multiple sorting directions in the same way that
multiple sorting columns works?

And thanks for the submission info.  I'll get to that soon.

- dave

--
dave hendler
http://sollaires.net/
http://davehendler.com/
:wq


More information about the wp-hackers mailing list