5

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

marked as duplicate by Rarst Dec 4 '14 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. – fuxia 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... – torinagrippa 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. – fuxia May 13 '11 at 23:51
  • old post, but for anyone looking this is how i solved it: wordpress.stackexchange.com/questions/38075/… – helgatheviking Jul 17 '12 at 20:12
0

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?

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