To order by event-end date or start date, your write separate function and call them as per requirement. For example if user clicks on order by start then start function should be called.
switch($orderby){
case: 'event-start':
# your code
/*
$query['meta_key'] = 'event_start_date';
$query['orderby'] = 'event_start_date';
*/
break;
case 'event-end':
#your code
/*
$query['meta_key'] = 'event_end_date';
$query['orderby'] = 'event_end_date';
*/
break;
}
Related Posts:
- Sorting posts by custom date fields (non standard date format)
- Order posts by date and then by custom field
- Order Posts by meta value AND published date
- How To Fix WP Query Returns Results But Shouldn’t?
- Understanding the orderby in WP_Query?
- Order by empty custom field
- Order Custom Post Type by Custom Field Value
- meta_value_num not ordering all items
- filter wp_query result with custom field values
- Sorting posts by Multiple custom fields in defined order
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- WP Query with meta queries
- WP_Query, ACF field and array
- Order 2 meta_queries differently in WP_Query?
- Wrap group of wp query posts to parent div by date/year
- Order Custom Field by Price
- query_posts with sorting on a custom datestamp
- Query posts filter not working
- Display all custom meta field values from the database using ACF Repeater
- Best performance for use Custom Field in WP
- WP_Query sort by ACF date field (newest first) with blank dates first
- Sort wp_query of two post types using meta datefield for one and date for the other – possible?
- WP_Query – Order results by meta value
- Can wp_query return posts meta in a single request?
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- WP_Query orderby date not working
- Meta query with string starting like pattern
- compare meta_query in get_posts arguments
- Order by optional meta key?
- How can I use order_by to order by two meta_keys without excluding posts that don’t have those keys initialized?
- Sorting: custom query with orderby meta_value_num THEN by title
- Order by DESC, ASC in custom WP_Query
- WP_Query order by multiple meta keys & fields
- Display List Of Posts Containing a Relationship Field Value [ACF]
- Function in array as arguments for WP_Query
- Using OR conditions in meta_query for query_posts argument
- Secondary Sort (fallback) for WP_Query
- Query Posts in a Predefined Order
- WP_Query to show post from a category OR custom field
- How to get order of posts?
- Order posts by ID in the given order
- ACF Relationship Field Search Filtering [closed]
- Custom WP_Query order by post_meta and (author) user_meta
- Filtering a WP_Query meta_query by numeric values isn’t working
- Getting attachments by meta value
- meta_query where value is equal to given value
- How to order posts tag by tag?
- How do I order pages and categories by ID or name in the same query?
- ACF datepicker meta_query Compare Dates in m/d/Y g:i a – Not in Ymd Format
- Get_post() with meta_key when compare is a date
- WP_Query ordered by custom field that is a date string?
- querying with custom meta field with meta_query
- Group posts by custom field
- WP_Query sort by comment meta data
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- Trying to perform complex custom field query with order by set to field value
- WordPress meta_query and order by custom field
- Order Posts by Closest Numeric Values
- Order posts by tags count?
- Merge 2 args in one WP_Query and order it by date
- Orderby = none not working [duplicate]
- getting posts and number by specific meta value in multiple meta
- How to query using a combination of custom_field values?
- WP_query ‘orderby=none’ Problem
- Sorting Posts by custom field
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Order Custom post type loop by custom field (datepicker)
- Query two post types and order by two different date fields
- Order posts ascending with number in title
- List taxonomy terms plus their latest post ordered by post date
- WordPress altering my custom query, How to fix it?
- Order by the results of a function with WP_query
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- meta_query with array as value
- query posts in functions.php and update a field
- How to order posts in wp_query by a meta_value of the corresponding author
- Order by meta_key in custom post type doesn’t affect the query
- Order by menu structure
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- meta_key and meta_value not working together
- How can i make WP_Query return post image and categories?
- WP_Query order by date in meta_value
- Custom Field sort not working (WP 3.8.1)
- Advanced Custom Fields query
- How to use order RAND() on WordPress?
- Display posts if a custom field value is equal to another custom field value
- Show all parents and children in custom post type in right order
- wp_query with multiple custom fields
- Ordering by meta_value AND date NOT WORKING with wp_query
- WP_Query orderby breaks when using AJAX?
- Order WP Query posts by custom order calculated from post meta values
- How add a custom posttype name using ACF field to a query post array
- Filtering posts by custom field value not working
- Custom Post order for homepage
- Minimising number of queries on a page when using Advanced Custom Fields
- Meta query with order by another custom field
- Change default ordering of taxonomy terms – pre_get_terms
- Display link to taxonomy archive only if it has posts with certain custom field values
- getting posts and number by specific meta value in multiple meta