I think this is the syntax you are after:
$args = [
'posts_per_page' => 5,
'post_type' => 'post',
'meta_query' => [
'relation' => 'OR',
'rating_au_clause' => [
'key' => 'rating_au',
'compare' => 'EXISTS'
],
'rating_overall_clause' => [
'key' => 'rating_overall',
'compare' => 'EXISTS'
]
],
'orderby' => [
'rating_au_clause' => 'ASC',
'rating_overall_clause' => 'DESC',
],
];
It’s a subtle difference, but uses your named meta queries in an orderby array.
Related Posts:
- How can I create a meta_query with an array as meta_field?
- How can I query all users who registered today?
- How to List Events by Year and Month Using Advanced Custom Fields?
- Compare two numeric custom fields
- Advanced Custom Fields – Query Efficiency
- WordPress creating excessive joins on meta_query with search
- How to display liked posts of current user in wordpress?
- can’t get query to order posts by acf datepicker
- How can I apply a meta query for a single custom post type in the main query?
- How do I find if a page has a template?
- How to check current user in meta value array in WP_Query meta_query
- Query metas (and not : query posts by metas)
- Order posts by custom field DATE value
- How to orderby multiple meta fields with another meta query
- Query returning same results even though the ID changes
- Order by meta value pro first then meta value free in my search function
- get_users with array as meta_value
- Get the_field of Advanced Custom Fields in a custom query [closed]
- Advanced Custom Fields – Relationship post foreach query
- get_post_meta with WP_query
- Querying Advanced Custom Fields
- WordPress Mysql query and Duplicate
- How can I get the name of term post meta value which equals term id
- How to “orderby” the first array in a meta_query that uses multiply keys?
- Exclude in get_pages() based on meta field
- meta_query not working
- Restrict WordPress search to a single ACF field
- wp query multiple values > display a specific value first
- Is there any way to get all custom posts and all custom terms with it’s meta in few queries?
- Slow wp_posts and wp_postmeta query using Advance Custom Fields
- How can I modify standard search query to include also ACF custom fields values?
- WordPress search form and search result through ACF field in custom taxonomy
- Fastest and most efficient SQL query to check if UID exists
- Query Posts that have or don’t have a meta_value and order by the same ASC
- What is the best way to query posts based on live data?
- Advanced Custom Fields Query with Different Values of the Same Key
- list or get meta_key where meta_value is ‘something’
- WP_Query orderby meta key/value suddely stopped working
- Modify a query using both a text field and a true/false AFC field
- Meta Query compare with LIKE pulls similar post types: 55 and 155, and 1,155
- Use value from meta key array for use in WP_Query
- How to use meta_query to retrieve posts from multiple custom post type
- How to display SQL query that ran in query?
- Query multiple meta key values?
- How to Optimize WP site for millions of posts
- Filtering multiple custom fields with WP REST API 2
- How to get comments by post ID?
- 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
- 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?
- Matching Serialized Arrays with meta_query
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Meta Query with AND & OR?
- 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
- ACF Relationship Field Search Filtering [closed]
- Is there any difference between hooks posts_where with posts_join and posts_search performance wise?
- Custom WP_Query order by post_meta and (author) user_meta
- wordpress query – orderby child post date
- Query WooCommerce orders where meta data does not exist
- Filtering a WP_Query meta_query by numeric values isn’t working
- How many WordPress SQL Queries per page?
- How to display Section for certain time
- Add multiple value to a query variable in WordPress
- 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
- Custom Queries: Joining On Meta Values From Two Custom Post Types
- What is the most efficient way of implementing a favorite post system?
- Remove [gallery] shortcode altogether
- wp_dropdown_categories with multiple select
- Why does get_the_time(‘F j’) return November 30 for all posts?
- ACF datepicker meta_query Compare Dates in m/d/Y g:i a – Not in Ymd Format
- 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?
- Perform query with meta_value date
- Custom query filter not working on woocommerce category page
- How to delete a transient on post/page publish?
- WP REST API: Order posts by meta value (acf)?
- 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?
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- 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?
- Meta Query “IN” doesn’t work with ACF checkbox filter
- 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