Okay, I found the problem by debugging the query.
It was a generic LEFT JOIN
added with the posts_join
filter that has not alias the $wpdb->postmeta
table which finally leads to the error.
So the sorting is working now without problems.
Related Posts:
- Custom query filter not working on woocommerce category page
- $query->query_var[‘post_type’] not set for pages
- Filter query posts by the count of metas for a meta key
- How to set back query var author_name after unset it?
- Change searched term
- pre_get_posts : ‘post__not_in’ doesn’t work with global variable
- How to change the amount of posts previewed on a page?
- How to reset usual $query on search page to push custom $wpdb query there?
- Merge CPT Taxonomy and Post Taxonomy in $query->set
- New custom post type entries are not sorted correctly in admin using pre_get_posts
- Limiting a filtered query
- Why the pre_get_posts hook can cause apache stopped working?
- excludeCat function reverses order of blog posts
- Run search query again without pagination gives no results?
- Set posts per page for parent category and it’s all children
- Filter multiple different main queries on custom pages
- Modify a query using both a text field and a true/false AFC field
- How do I troubleshoot Maximum execution time of 60 seconds exceeded in updating a Media File?
- Admin Post List table Query filtering “WHERE” for custom post type
- pre get posts not working with Tribe Events
- Can I filter existing search query using pre_get_posts for post_mime_type?
- How to display SQL query that ran in query?
- How can I create a meta_query with an array as meta_field?
- Query multiple meta key values?
- How to Optimize WP site for millions of posts
- How to get comments by post ID?
- Media library to list images only user uploaded
- Differences between wpdb->get_results() and wpdb->query()
- Is there a way of increasing the speed of this query?
- Get all image from single page using this query
- How can I query all users who registered today?
- Get Terms by IDs with IDs order
- Reversing the order of posts AFTER the query is performed
- what are the numbers between curly brackets in search query
- simple sql query on wp_postmeta very slow
- Using WordPress public query variables
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- When/why does ‘$query->get( ‘tax_query’ );’ return empty?
- is_category() in pre_get_posts strange error
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- How to get link and title of next and previous post on single page
- Create pagination and order according to alphabet
- wpdb get posts by taxonomy SQL
- How to uniquely identify queries?
- How to List Events by Year and Month Using Advanced Custom Fields?
- Is there any difference between hooks posts_where with posts_join and posts_search performance wise?
- complex restriction of items in media library
- wordpress query – orderby child post date
- How many WordPress SQL Queries per page?
- pre_get_posts with get_posts
- How to display Section for certain time
- Add multiple value to a query variable in WordPress
- Add Custom Post Type to Current Query
- Search custom post type by meta data
- Custom query_var causes displaying posts archive on front page
- Slow wp_enqueue_media()
- Multipart/formatted MySQL query problem
- What is the most efficient way of implementing a favorite post system?
- Remove [gallery] shortcode altogether
- Compare two numeric custom fields
- wp_dropdown_categories with multiple select
- Advanced Custom Fields – Query Efficiency
- Why does get_the_time(‘F j’) return November 30 for all posts?
- Query by one meta_key and sort by another (possibly NULL value)
- How to tune search argument in WP_Query to show only exactly the same results?
- How to delete a transient on post/page publish?
- Very slow query
- query multiple taxonomy and show post count
- Search Terms – Querying on either description__like OR name__like in the same Term Query?
- WordPress Number of Posts Not Changing With posts_per_page
- Query & Sort Comments by custom comment meta
- How to get my loop to pull posts into three columns
- How to display lastest post date in the homepage?
- Custom $wpdb Query for Custom Post Type by Category
- Get a user’s most recent post title
- Categories and products in random order
- add_query_arg() XSS Vulnerability
- Count user posts by user ID, Post type and Post status
- Can’t pass table to $wpdb->prepare
- Query set using tax_query with relation ‘OR’ modifies category object?
- is_archive() doesn’t work on public query var archive pages?
- is_category in pre_get_posts results in php notices
- How to extract all ID variables from a query string?
- When add_query_arg() is necessary?
- Different Main Navigation per category
- How to get category link without a database query
- Insert html after certain amount of posts?
- wp remove query
- Show recent products first but “sold out last” in query
- WordPress creating excessive joins on meta_query with search
- How to display liked posts of current user in wordpress?
- Can not switch the queried post in pre_get_posts hook
- How to tell if $query_var isset?
- Show All Posts Insert Edit Link
- $wpdb->get_var not returning a result
- search through post-type attachments titles
- How to count get_users query?
- Date query year and month OR just year
- cron job to auto delete posts of a specific post type older than x days
- Possible to get posts from multiple meta keys/values in a single query?