As you can read in Codex about orderby
and the WP_Query
, you can use multiple orderby values as well:
'orderby' => 'name meta_value'
simply by using a space in between. The available orderby values are listed in the Codex page.
About your question: By default it should already work with your query. If it doesn’t, you’ll have to add the output from posts_clauses
, posts_request
or use the pre_get_posts
filter. More details in this answer.
Related Posts:
- How Do I Use WP_Query to Run This Database Query as Search Result?
- WP_Query of custom post type sorted by meta_key has unexpected results
- WP_Meta_Query object with conditionals
- Use WP_query to match post types based on custom field values
- Querying meta values within an array
- Query all posts where a meta key does not exist
- Meta query with boolean true/false value
- Get post with multiple meta keys and value
- Mixing regular and custom post types (with meta_query) on home page
- WP_Query() show posts that end later than today
- WP_Query orderby custom field then post_date in one query
- Filtering a WP_Query meta_query by numeric values isn’t working
- Ordering posts having multiple post-meta date fields
- Include post id[s] into WP_Query()
- Custom Queries: Joining On Meta Values From Two Custom Post Types
- How Can I save multiple records in same meta key?
- Pre_get_posts Gives 404 on Custom Post Type
- filter search result with custom post type meta key
- I can’t set meta_key in my custom post type query
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Using Query Posts With Multiple Post Types And A Taxonomy
- Display two post types ordered by two custom fields
- Combine tax_query and meta_query in WP_Query
- Query for posts from any post type but only add instock products
- query order by date on custom type: wrong order
- exclude custom post type by meta key in wp_query
- Display all Posts and only certain Custom Post Types with meta fields
- Displaying Metabox value (custom post type taxonomy)
- Filtering by Post Meta Custom Fields – Performance
- Custom search for custom post meta with pre_get_posts interferes with WP search
- Is it possible to apply a meta_query to one specific post type in a query with multilple post types?
- WordPress Orderby Numeric Value Not Working
- Setting proper query for multiple custom admin filters
- WP_Query: include custom post type only with specific meta value
- Returning a list of custom post types excluding those without a specific meta_value
- Display custom post type from dynamic custom field
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- wp_query check if integer exists in custom field’s array
- Get posts between custom dates
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- How to do WP_Query with two meta fields with orderby clause
- Stuck in Order by more then one
- Why is this query not working? (Standard posts + custom post type)
- WordPress request fiter order by related post’s post_title
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Possible to filter custom post type with multiple meta data?
- Query based on custom fields start and end date
- Displaying a div from an assigned meta_value when on a page
- WP_query – Filter by tax_query and meta_query using multiple select
- How to get specific post meta by title or id
- Getting a custom post’s custom field based on another custom post’s custom field select
- how to show records that don’t have custom meta value
- find custom post type post by searching its custom field with my string
- $post->post_meta not pulling any post in wordpress/php
- Returning a custom content types with meta values
- How to query for posts (hierarchical custom post type) that have children but are NOT top level?
- Create a WP_Query where if the first value of the first row is equal to the second compare other value
- Query Posts, order by meta value
- Sorting by meta_key different to search criteria?
- Using WP meta query to show custom post types by a start and finish date
- Two queries – one with checkbox ticked, one without – comparing meta_query
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- After inserting new post with wp_insert_post() the post is not visble to WP_Query, but the same WP_Query works for post inserted from wp-admin panel
- Query to Exclude Child Pages from Custom Post Type Archive
- build child and anchestor three from post parent
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- meta query condition don’t work
- Custom query result empty on page 2
- How to sort by multiple values in a nested WP_Query
- Show posts from WP Custom Post Type selected from a field in a metabox
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- meta query multiple values for the same key
- How to get post by meta value
- Sort custom post archives by a meta value from a different custom post type?
- Custom post types – meta_query: search lesson which starts sooner
- How do I get all authors posts of a custom post type outside loop
- post type => ‘any’ not applied my custom queries
- How to get the posts that my following users are liked?
- Linking posts together with Advanced Custom Fields “both ways”
- Not able to get my custom search result using meta_query and tax_query together?
- pre_get_posts gives 404 error on Custom Post
- Meta query broken since 4.7.4 Update
- How to get Current week and current date record wp query
- Querying, storing, and using data from 2 separate custom post types
- get_post_meta for Custom Post Type ( CPT )
- Custom Post Type shows pagination (w/404) or posts_per_page query, but not both
- meta query always fails even if data is correct
- WordPress custom post type
- Selecting posts older than the current Unix epoch timestamp
- Custom Post Type meta oembed html output resulting in WSoD
- Values inside a custom field to determine which category posts to display
- Custom Query With Multiple Meta Key Value
- How do I sort post listing by child post count?
- Trying to combine multiple WordPress queries
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Check for custom field value in different post type than current one and do something
- Order Wp Query by earliest of 3 dates meta query
- WP_Query() displaying past post / event
- WP Query Conditionally query meta and taxonomy