[wp-hackers] custom post types: order by taxonomy
otto at ottodestruct.com
Mon Mar 7 20:48:20 UTC 2011
On Mon, Mar 7, 2011 at 2:36 PM, Travis Northcutt
<travis at travisnorthcutt.com> wrote:
>> It's not possible to order by terms in a taxonomy, because it doesn't
>> make any real sense to do so.
> I can imagine a situation where it would make sense to order by terms in a
> taxonomy. Let's say you've got a 'home' post type (i.e. a house), and you
> have a taxonomy for number of bathrooms, as well as number of bedrooms.
> It would make perfect sense to be able to sort by number of bathrooms or
For the case you're describing, you would more ideally have them as
postmeta (bedrooms->3, bathrooms->2.5, size->2400, etc) and thus could
sort them by those if you wanted.
A taxonomy doesn't make sense for these types of things, because you
wouldn't use them as a grouping mechanism. You don't group homes by
number of bedrooms, generally speaking. You might want to only show
homes with 3 bedrooms, but that's just the way you select them, not a
way you group them together into categories. A more natural grouping
mechanism might be by neighborhood or street. That would make more
sense as a taxonomy, because it's grouping the homes together in some
fashion that is natural and not a specific property of the homes
Meta should be used for anything descriptive about the specific piece
of content. You can select based on meta data, and order by it as well
(with either alpha or numeric ordering). The new meta_query lets you
make complex queries based on it, if you want.
Taxonomy should be used to group pieces of content together in a
natural way. If you're using the terms of a taxonomy to describe
things, then you're using it wrong.
More information about the wp-hackers