meta_query
and orderby
are seperate parameters, you just put them together in an array. You will have to do one then the other.
e.g.
<?php
$args = array(
'post_type' => 'property',
'meta_query' => array(
array(
'relation' => 'AND',
'city_clause' => array(
'key' => 'city',
'compare' => 'EXISTS',
),
'street_clause' => array(
'key' => 'street_name',
'compare' => 'EXISTS',
),
)
)
'orderby' => array(
'city_clause' => 'desc',
'street_clause' => 'desc',
)
)
?>
https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
Related Posts:
- Posts with at least 3 tags of a list of tags
- Get post count of current loop when using multiple queries on one page
- Display products from specific category in shop page
- Hook/action after WP_Query gets posts to query custom tables for post-related meta
- WP_Query to show post from a category OR custom field
- Is it possible to select against a post’s parent’s fields with WP_Query?
- Get posts by meta data OR title
- Display Posts by modifying the where clause only for my query
- page was loaded over HTTPS, but requested an insecure image
- WP_Query: How do I sort on meta value and use LEFT JOIN?
- Pagination causes error 404 when used with front-page.php
- How to pass custom parameter to WP_Query for filtering in pre_get_posts
- WooCommerce: filter by parent product’s taxonomy and product variation’s meta data
- How to search by title or tags exclusively?
- Paginated pages are showing correct content but pagination links are not
- Query Posts but only return 1 from a custom taxonomy?
- Using AJAX to return search form results
- Add custom search results to main WP search [duplicate]
- What is the difference between RELATION “AND” and “OR” in TAX_QUERY?
- Finding post content that begins with a specific character
- Query Set Order By Author
- ‘&’ causes an error in my shortcode when I list the content of the page
- wp_query, give first post different formatting
- SQL Query inside Widget
- meta_query works locally but not on live server
- getting posts and number by specific meta value in multiple meta
- Use ‘parse_query’ filter to show posts that from multiple criteria
- How can I pick a single post from the latest 3?
- Retrieving list of a custom post type in a widget without using WP_Query?
- Get posts for last working week in WP_Query
- How to orderby meta_value_num with dollar ($) sign
- how to link to detail page(single.php?) in a wp_loop
- WP_User_Query unable to retreive all user at once
- Order WP_Query by multiple fields, subtracting them from one another
- Meta Query Array Error 500
- getting post thumbnail within loop causes an error
- Reset postdata to custom query in nested queries
- Complex WP SQL Query
- Hide Administrators From User List except current user (administrator)
- Custom Query num_rows returns wrong amount
- How to figure out redirection and contents in hybrid solution containing word press content and legacy code (ASP.net)
- Category applied to pages, creates multiple breadcrumb entries after a search query (On the translated site)
- Most commented post showing 2 records
- How to store and receive variables in WP sessions?
- Add posts to WP Query object
- How to list posts with disabled/closed comments, with pagination?
- Category ‘pad_counts’ & ‘parent’ conflict
- WP User Query with Custom Fields and Search Results
- Order or Orderby in tax_query (How to define order of terms in WP_Query)
- Event with multiple dates, display events chronologically
- How to exclude Sticky from Recent Post?
- Display if author page is author page of current user
- Create a loop on my pages with new “WP_Query”
- WP_Query order by not working properly due to category I believe
- get_query_var always returns the default value
- WP ForLoop to compare meta information of posts to determine what post to display
- Modify WP_Query using pre_get_posts but only for frontend query?
- Multiple wp_query on archive page
- WP_Query to get post on frontpage
- When listing child pages run out of memory
- Function to retrieve IDs of posts, cache results, and improve wp_query
- parse_tax_query causing Navigation Menu To Disappear
- WP_query is not returning the expected result
- the_post_thumbnail do 2 queries. How to optimize
- wp query meta value is not null
- Trying to use WP_Query to display a custom post type
- Search.php – return number of results but cannot loop through
- Creating ‘posts page’ loop based on the page itself
- How to get pages of parent (non-recursive)?
- WP_Query and pagination AGAIN?
- Can’t get term id for category archive
- Combine query in WP_User_Query()
- Nearby locations using Advanced custom fields, maps?
- How to display the category dropdown auto search list when key press?
- order by post date and modified date posts both in wpquery
- How to get_comments() ordered by date and parent?
- WPQuery loop not giving expected output
- WP Query filters active on wrong query
- Not able to fetch woocommerce variation sales products for particular category products
- Global page ID variable empty error
- WordPress tax_query ignoring relation OR
- pagination functions are not working
- Gather same custom field values in one value in a select tag with wp_query
- Continue loop after $queryObject
- Order Posts By Youtube Views
- WP Query with sticky posts and tax_query
- Declare inline background image in functions.php
- WP_Query for attachments without duplicating post_parent and displaying tagged image
- Looking for a way to exclude frontpage and nav menu from query filter
- Using Query In Post Type Archives
- Query posts by custom fields
- Showing posts from 4 categories along with all latest posts
- Searching in specific custom post type
- WP Query Obj: Set value to be unequal | Hide media by admin
- WordPress pagination returns the same posts
- Using ‘meta_query’ with the ‘pre_get_posts()’ hook disables searching for post titles
- Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise
- Get posts using multiple values from ACF checkbox as meta query wordpress
- How to save the results of a query as a php file for an autocomplete search bar
- Why ignore_sticky_posts argument is in sticky post query?