Order posts by value of two fields
-
I’m currently fetching posts where event_start_date is on or after the current day’s date and am displaying the posts in ascending order. Current working code…
$posts = get_posts(array( 'post_type' => 'post', 'post_status' => 'publish', 'post_category' => 'events', 'posts_per_page' => -1, 'meta_key' => 'event_start_date', 'meta_value' => $today, 'meta_compare' => '>=', 'orderby' => 'meta_value_num', 'order' => 'ASC' ));
I now need to modify my code so that my posts will be displayed oldest-to-newest by event_start_date (as is currently the case) and then secondarily by event_start_time (which is not currently the case).
To make things more fun, the value in event_start_time is in the format “10:00 AM” or “9:00 PM”, etc.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Order posts by value of two fields’ is closed to new replies.