WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 '14 at 12:27

This question was marked as an exact duplicate of an existing question.

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
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
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.