Sort Custom Post Type Archive by Taxonomy Term [duplicate]
-
22-10-2019 - |
Question
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...
Solution
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
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange