I have some 'Events' custom post types. On the home page of my site, I'd like to show the last X events, but in ascending order of time (earliest first). Where I am stuck is that to get the "last X" entries, I need to put the event date field in DESC order in the SQL, but after those posts are retrieved, I need to order them in ascending order.
// get posts $posts = get_posts(array( 'post_type' => 'events', 'posts_per_page' => 2, 'meta_key' => 'from_datetime', 'orderby' => 'meta_value', 'order' => 'DESC' ));
from_datetime is my custom field using ACF. This works. It gets me the last two events. But they're in descending order of time, which means the further event is first.
Is there a way to get the last 2 events, but in ascending order of time from get_posts itself, without resorting to some array or something from the results?