Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This question already has an answer here:

What is the best method (as of 3.1 or 3.2 beta) to sort a custom post type archive by a given taxonomy term?

I'm trying to make a staff page and I want to sort employees by department. So the taxonomy would be staff and the terms to sort would be sales and support.

I tried query_posts and WP_Query but perhaps I messed up the arg array...

share|improve this question

marked as duplicate by Rarst Dec 4 at 12:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3  
For mutually exclusive terms use post meta not taxonomies. Sorting is easy then. –  toscho May 13 '11 at 13:57
    
I thought of using post meta but as I understood it taxonomies are for grouping large numbers of posts within a few variables. If I can't find a good way to do it with taxonomies I will definitely have to go this route... –  mattrepublic May 13 '11 at 23:41
1  
One object may have more than one taxon from each taxonomy. That’s the basic difference to post meta values. The other: Queries for post meta touch just two tables, not three like for taxonomies. –  toscho May 13 '11 at 23:51
    
thanks @toscho for the clarification! –  mattrepublic May 15 '11 at 16:03
    
old post, but for anyone looking this is how i solved it: wordpress.stackexchange.com/questions/38075/… –  helgatheviking Jul 17 '12 at 20:12

1 Answer 1

up vote 0 down vote accepted

Good question - I'm fairly sure you can't do this just using wp_query.

You'll need to either add a posts_groupby filter, or just query the database directly. This previous question and answer might be helpful

Using wp_query is it possible to orderby taxonomy?

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.