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
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- How can I use order_by to order by two meta_keys without excluding posts that don’t have those keys initialized?
- Custom WP_Query order by post_meta and (author) user_meta
- How to order posts tag by tag?
- Trying to perform complex custom field query with order by set to field value
- 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 by the results of a function with WP_query
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- How to order posts in wp_query by a meta_value of the corresponding author
- Order by menu structure
- meta_key and meta_value not working together
- WP_Query orderby breaks when using AJAX?
- Order WP Query posts by custom order calculated from post meta values
- Change default ordering of taxonomy terms – pre_get_terms
- Ordering Posts Type A by Custom Fields of related Post Type B
- Query Posts depends on custom field inside repeater field using acf
- Wp query orderby ‘title’ doesn’t work
- How can I order Wp_Query hierarchically?
- Search Posts with Custom Fields as query
- ACF Date Based wp_query
- exclude posts with a specific custom field and value
- (Solved) WP_Query ($ args) -> How to sort letters and numbers within the same array
- Complex WP_Query order request: DESC by day, but then ASC by time
- Any number in meta key (wp query)
- How do I correctly set up a WP-Query to only show upcoming event-posts?
- Sort wordpress custom posts based on meta value
- WP_Query order by custom field, then randomly order some of results
- meta_query BETWEEN, but the range is stored in the custom field
- Get a list of posts with associated meta_value
- WordPress Comments sort by custom meta key
- Order by summing multiple values
- How to list custom fields as headers and list all pages sharing that custom field under it?
- Order ascending is ignored in meta query?
- Search posts missing a particular custom field
- How to Order a list of taxonomies? orderby?
- Conditional operator OR not working with custom fields
- WP_QUERY with group by with custom fields
- Posts query according to meta box date
- create metabox to activate slider
- Query posts using less than
- Expecting statement error from php loop using ACF plugin
- Query only displays one page_id
- Display post meta conditionally based on it’s value
- Query using string from custom field as array value
- How to show list of posts with custom field value (a date) that are coming soon
- Randomly select one of last 3 posts
- how to retrieve WP_Query without ordering by date [duplicate]
- WP Query orderby ACF boolean values and ACF field value
- meta_query weird behaviour, static int will work, but not user data
- WP_Query orderby
- How to sort store location by specific category order in WP store locations
- Excluding posts from search results page with meta query not working
- Query posts by post type, author and post meta
- How to use the Term Object from a custom select field in a query
- ACF: How can I publish values of ACF fields in a loop while using wp_query?
- Trouble with serialized metadata
- Query on a repeater date (acf)
- WP_Query random ordering not working since 5.4
- Query for getting posts with their custom fields data in WordPress
- How to rearrange posts based on input field values added by WordPress “Advanced Custom Fields”
- Problem with my loops
- Sort posts on custom field AND after that sort on date?
- Query string order by custom field
- WP_Query sort by meta_value_num or date
- Display three sequential posts on each page load, without repeating previous
- Object of class WP_Query could not be converted to int inside shortcode
- Find by post_meta, then sort by post_meta, then sort by date (wp_posts)
- WP_Query within save_post doesn’t include the item that triggered the action?
- Issue in If else condition [closed]
- How do I display posts with specific value in a custom field into my loop?
- The sorting of posts by a meta_query with two keys fails while separated as single queries it works
- $args Orderby The number
- Order by multiple meta keys on wordpress
- WP_Query with several meta_query-statements and order by meta_value
- Output ACF field dynamicaly within a taxonomy loop [closed]
- I want to place a post before all others from an ACF boleen field
- How to put posts with some taxonomy on top of others in `pre_get_posts`
- Use value from meta key array for use in WP_Query