[wp-hackers] Filter on one meta value and sort by another

William Davis will.davis at gmail.com
Tue Nov 30 20:26:50 UTC 2010


Simon,
I would recommend using custom taxonomies (http://codex.wordpress.org/Custom_Taxonomies 
). I think that will solve your problems.

William P. Davis
will.davis at gmail.com
207.660.5342
http://twitter.com/williampd
http://www.wpdavis.com



On Nov 30, 2010, at 3:17 PM, Simon Blackbourn wrote:

> i'm building a listings site, where each post has two meta keys:
>
> - 'status' which can be a number of different values (e.g. active,
> scheduled, awaiting payment, expired, error),
> - 'type' which can be a-premium, b-standard or c-normal.
>
> on all multiple post pages (index, search, taxo, etc) i need to show  
> only
> those posts with a status of active, and they should be ordered by  
> type (so
> that premium listings appear before standard ones).
>
> the first bit is easy enough, but i'm completely stuck on the second!
>
> can anyone help with the SQL i need to achieve filtering on one meta  
> value
> while ordering on another?
>
> i've pasted my current code at http://php.pastebin.com/Jg58KSz1 ,  
> this does
> the filtering bit but not the ordering.
>
> (ideally i would use custom post statuses for this, but this is not  
> yet
> fully developed enough in core to be usable.)
>
> many thanks
> simon
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list