I found out the answer myself.
There are other filters that let you adjust the query before it’s run:
http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_clauses
The posts_clauses filter runs before the query gets executed and is essentially the sum of all filters that run immediately before it.
Apart from posts_clauses, there are several more precise filters that modify only a single specific clause:
- posts_where_paged
- posts_groupby
- posts_join_paged
- posts_orderby
- posts_distinct
- post_limits
- posts_fields
So in my case, all I had to do was to use posts_orderby filter.
Related Posts:
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- pre_get_posts order by not working
- Help ordering Post loop by two meta values
- Order ascending is ignored in meta query?
- WP Query – order posts by meta field first and then order the rest
- Child pages not affected by orderby
- How to put posts with some taxonomy on top of others in `pre_get_posts`
- When to use WP_query(), query_posts() and pre_get_posts
- Should I use Pre Get Posts or WP_Query
- Using pre_get_posts with WP_Query
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- WP_Query orderby date not working
- What is “main query”? [duplicate]
- Order by optional meta key?
- Sorting: custom query with orderby meta_value_num THEN by title
- Order by DESC, ASC in custom WP_Query
- WP_Query order by multiple meta keys & fields
- Reduce or prevent calling of update_meta_cache
- How to add taxonomy filter on the query fly?
- Secondary Sort (fallback) for WP_Query
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Query Posts in a Predefined Order
- How to get order of posts?
- Order posts by ID in the given order
- How to uniquely identify queries?
- Order Search Results Page by meta_value If no Value Return Remaining Results
- Custom WP_Query order by post_meta and (author) user_meta
- Sorting posts by custom date fields (non standard date format)
- pre_get_posts with get_posts
- How-to exclude terms from the main query the most performant way?
- Changing Posts Per Page and offset with pre_get_posts
- How to order posts tag by tag?
- Slow SQL_CALC_FOUND_ROWS Query
- How do I order pages and categories by ID or name in the same query?
- “pre_get_posts” firing on every query
- RSS feed with specific keyword
- Using is_main_query to select custom post type on certain page
- WP_Query ordered by custom field that is a date string?
- Multiple orderby parameters in pre_get_posts() action
- WP_Query sort by comment meta data
- SQL Statement generated by WP_Query not producing expected results
- Order posts by tags count?
- Merge 2 args in one WP_Query and order it by date
- Orderby = none not working [duplicate]
- WP_query ‘orderby=none’ Problem
- Sorting Posts by custom field
- Order posts by date and then by custom field
- How to pass custom parameter to WP_Query for filtering in pre_get_posts
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Query with pre_get_posts to get pagination
- Revolution Slider Orderby Two Custom Fields
- Recommended way to drop a pending query (in pre_get_posts)?
- Single page theme that uses pages for the content
- Order posts ascending with number in title
- List taxonomy terms plus their latest post ordered by post date
- Order by the results of a function with WP_query
- WordPress custom search form with pre_get_posts not work
- If orderby parameter using pre_get_posts is the same for multiple posts what fallback does the query use?
- Can not switch the queried post in pre_get_posts hook
- How to order posts in wp_query by a meta_value of the corresponding author
- How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?
- order by multiple meta keys in pre_get_posts
- Order by menu structure
- How to sort posts in admin by titles with dd.mm.yyyy format?
- WP_Query order by date in meta_value
- WP_Tax_Query with post_tag not working
- Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
- How to Modify Taxonomy Archive Page with Search Parameter?
- How to use order RAND() on WordPress?
- Show all parents and children in custom post type in right order
- Using pre_get_posts on a specific core/query block
- Ordering by meta_value AND date NOT WORKING with wp_query
- WP_Query orderby breaks when using AJAX?
- Order WP Query posts by custom order calculated from post meta values
- Searching through different categories on different pages code is not working
- How to display future posts – modified query still yields 404
- Custom Post order for homepage
- Meta query with order by another custom field
- Change default ordering of taxonomy terms – pre_get_terms
- WordPress WP_Query orderby being overwritten
- pre_get_posts filter meta_query without conflicting existing meta_query
- WP_Query Order by Specific Post ID First
- Including only current user’s posts in search
- When querying a combination of posts and other meta fields, is there a better solution than directly modifying the WHERE value?
- Order Posts by meta value AND published date
- How to change posts order on Category and Tag archives?
- How can I pick a single post from the latest 3?
- Wp query orderby ‘title’ doesn’t work
- How can I order Wp_Query hierarchically?
- How do I sort posts with multiple pages
- Sorting posts DESC based on the number of comments using WP_Query
- Formulate a url to show posts with both taxonomy terms
- My Main Query Modification is Messing up my dynamic main – why?
- Offset Page Loops and Pagination
- pre_get_posts Remove tax_query Completely
- Order WP_Query by multiple fields, subtracting them from one another
- Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?
- Adding a parameter to the default query
- Using WP_Query in “parse_query” or “pre_get_post” in Posts2Posts
- Single meta_query query using OR instead of AND in request’s WHERE statement