Sort Custom Post Type Archive by Taxonomy Term [duplicate]
IT Nursery
May 5, 2022
0
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…
1 Answer 1
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?