You’ve already named the clauses in your meta query, so you can reference these directly in the orderby
argument:
$query->set(
'orderby',
array(
'enddate' => 'DESC',
'startdate' => 'DESC'
)
);
Related Posts:
- How can I create a meta_query with an array as meta_field?
- How can I query all users who registered today?
- WordPress creating excessive joins on meta_query with search
- How to display liked posts of current user in wordpress?
- 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)
- 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_post_meta with WP_query
- WordPress Mysql query and Duplicate
- How to “orderby” the first array in a meta_query that uses multiply keys?
- meta_query not working
- WordPress query: merge meta key (number) values and sort
- Restrict WordPress search to a single ACF field
- Is there any way to get all custom posts and all custom terms with it’s meta in few queries?
- 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?
- list or get meta_key where meta_value is ‘something’
- WP_Query orderby meta key/value suddely stopped working
- Meta Query compare with LIKE pulls similar post types: 55 and 155, and 1,155
- Get all image from single page using this query
- wordpress query – orderby child post date
- Add multiple value to a query variable in WordPress
- wp_dropdown_categories with multiple select
- How to tune search argument in WP_Query to show only exactly the same results?
- How to get my loop to pull posts into three columns
- Custom $wpdb Query for Custom Post Type by Category
- Can’t pass table to $wpdb->prepare
- Date query year and month OR just year
- Are database queries created using WordPress filters protected from SQL injection?
- get post id using the $query_vars variable
- How to remove duplicate query on page load or make them cacheable
- Is there a conditional tag for latest post or do i need a query?
- wpdb::prepare() isn’t working
- get_posts() loop returns the same the_title() for each post
- How select a specific query when setting offset?
- Change media attachment author via mysql query
- Temporarily storing main search result
- Query posts if meta key starts with
- Help with MySQL to $WPDB query
- Query based on title, with ‘compare’ => ‘IN’
- Issue with using add_rewrite_rule() for post querying custom fields
- Form and custom query problem
- Export Specific User data without plugin
- Plugin will sort users by usermeta
- How to write: $wpdb->update having WHERE NOT value pair in the array
- Query posts according to specific post meta values
- wpdb COALESCE won’t work
- empty query breaks other queries
- Problem in exploding the_content to array
- Query does not return content
- What is wrong with my wp query, cant exclude the category that i want
- how to insert missing tags into the posts through mySQL?
- Parse query filter in wordpress and relation
- How to write update query in WordPress to expire transients
- Query Nickname rather than Display Name in custom Woocommerce plugin
- get posts by tag to showing in a widget
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- Get previous posts list
- how to replace old DW site with new WP site? [closed]
- WordPress SQL query to tag all posts containing a specific word on title
- Order terms by count – missing terms
- Querying Advanced Custom Fields
- How to rearrange a pool of posts joined using two queries?
- Why doesn’t my WP Meta Query return any results?
- wpdb update multiple row?
- Can I include get_posts in this array?
- Custom query Custom-Post-Types creates error
- Formatting a date/time returned from a custom $wpdb query
- Rewrite rule for query params
- Cannot get sql request from Query object?
- Hook into the Admin Dashboard and redirect users
- Displaying data from custom table
- SEO friendly query vars
- Prevent versioning for .woff (font) files
- Orderby event date (if it exists) or post date (if it doesn’t) – how to reorder posts based on meta value OR date
- OR condition not working
- Query by meta value (add a dropdown of all values)
- Query not returning child posts for any parent post ID
- Limiting a filtered query
- Use $wpdb->get_results with filter based on array
- Add Hook for clearing transient when post is added
- Advanced Post Display/Pagination/Ordering
- How to have more post in a page than in your home page
- Show links to child pages on both parent AND child pages
- Access Tables with number prefix
- Modify Global Posts Plugin
- How to reference same column name but different table in custom db query
- Retrieving custom field array value through db query
- SQL Query : how copy all tags of post into their post content in wordpress by sql query
- Get Posts ordered by a date custom meta field
- Query parsing only author ids
- 3 queries to update WordPress
- Use meta query only 3 or more results?
- How to figure out correct wp_options to have autoload=’yes’
- Use value from meta key array for use in WP_Query