Unfortunately, WordPress doesn’t have a built-in way to sort by taxonomy term. You do, though, have a couple of options.
-
You can iterate through your taxonomy terms and run a separate wp_query for each as this post shows.
-
You can directly manipulate the SQL query to achieve what you want. This article shows how. Look particularly at the last, Direct JOINs method.
Related Posts:
- How to sort a WP_Query array by post_name after an array_merge();
- Sort Posts with custom meta key by default which is currently set as optional
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- Sorting: custom query with orderby meta_value_num THEN by title
- Sort posts by category name and title
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- What kind of object type is WP_Query?
- How can I save an array from a random post sequence for later use?
- Getting an array out of WPQuery
- Loop through all tags & output posts in alphabetical list
- Use Transient API to cache queries for all posts in all categories?
- Sorting Posts by custom field
- Sorting meta_value as integer doesn’t work
- WP Meta Query for some meta (array) values
- meta_query with array as value
- Placing a div or img in between a post array using WP Query [closed]
- Front End Sorting Questions
- Sort by meta key on archive page
- How to sort posts in admin by titles with dd.mm.yyyy format?
- Query Set Order By Author
- WordPress: Keep order of query_posts list of post ID’s using post__in
- How to make orderby ‘meta_value_num’ OPTIONAL?
- Meta query with order by another custom field
- How can I get an array of all IDs from the current queried object?
- How can I pick a single post from the latest 3?
- How to orderby meta_value_num with dollar ($) sign
- How do I sort posts with multiple pages
- Minimize database queries to user tables?
- WP_Query posts by distance based on LAT & LNG in Database
- Changing WP_Query params with url Query Var
- (Solved) WP_Query ($ args) -> How to sort letters and numbers within the same array
- Sort wordpress custom posts based on meta value
- WP_Query: Group events by year, sorted DESC; then by date for each year group, sorted ASC
- Weird orderby => post__in issue
- WordPress Comments sort by custom meta key
- Understanding the orderby in WP_Query?
- How to list custom fields as headers and list all pages sharing that custom field under it?
- WP_query sorting can’t sort danish letters (æ, ø, å)
- Gallery shortcode numerical sorting
- WP Group posts by year(desc) > month(desc) > date(asc)
- Get posts by list of post IDs ordered by those IDs?
- Sort WordPress Posts Meta value by Week not Day
- Removing duplicate values between two wordpress queries
- How to order WP_Query to group results?
- Does meta_value (array) work with ‘orderby’?
- Combine 2 arrays in a query parameter
- Sorting search results with custom dropdown
- How to use a dropdown to filter posts by custom field
- How can I comment comma-separated array values?
- construct complex queries with WP User Query
- How do I sort this custom list of sticky posts
- WP_Query with page_ids in arguments without a result
- Related Posts Excluding Certain Categories
- Query using string from custom field as array value
- Multiple meta query from array
- Category based on post id
- How to avoid filling up an array each time I run a WP_query?
- Remove from array in WP_Query loop
- How to sort queried pages by an array of page ids?
- meta_query returning excluded result
- orderby ignored by wp_query
- Customize the Sorting Dropdown in WooCommerce use another list or more page
- Combine relationship posts with existing wp_query
- How to sort store location by specific category order in WP store locations
- Counting instances of words in the results of a post query
- Retrieve all custom field values of a specific custom field metakey as an array, inside WP_Query
- Sort by price wpdb
- WP Query by 4 different taxonomies
- Trouble with serialized metadata
- How sort products by calculate value? ( custom post meta, price, option)
- Get authors list and sort them by recent posts
- What code to use in an array to call the current sub-category?
- Loop through array of pages
- Order by value of Custom Field using url string
- WP Query with meta queries
- Order 2 meta_queries differently in WP_Query?
- Sort posts on custom field AND after that sort on date?
- Repeat array inside array through while loop
- Related Post by Tags Code
- Ignoring ‘a’ when sorting posts
- Display three sequential posts on each page load, without repeating previous
- Combine WP_Query with array of custom data to single loop without breaking the pagination
- Wrap group of wp query posts to parent div by date/year
- how to query for meta_value have array
- wp_query – Modify $query to include duplicate content
- How to get several fields from wp_query?
- Sorting is not working in WordPress WP_Query
- Issue with WP_Query (need a array of selected ID’s)
- WordPress WP_Query Array Custom search via taxonomies
- WP Query posts__in not working with array
- query_posts with sorting on a custom datestamp
- Dynamically name array in WordPress loop – add/get values
- Creating Custom Query
- wordpress sorting using array merge by price in ascending order but price with 0 must be show last
- have_posts order by title descending
- WP_Query – order with usort by custom meta
- How do I have multiple metaqueries inside one wordpress query
- I want to place a post before all others from an ACF boleen field
- wp_query, calculate with two dates when ‘key’ is text format
- Sort by multiple columns using get_posts