Does anyone know if it is possible to order a wordpress loop with multiple post types, but have each post type be ordered differently?
Say I have blog posts and events. Events have a start date and they should be in ascending order. The blog posts should be in descending order.
Suppose we're using pre_get_posts to try to filter this for the page loop.
You can specify anything you would use in a new WP_Query request, so we can set things like...
$query->set('post_type', array('posts', 'events'));
That much is working.
But as far as I know, there's no way to specify how to order an individual post type. Just the collection as a whole...
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
And I can't run a meta query on all results because only events have the start_date field populated...
So is it possible to do this within this hook?
I know how to do it by using multiple wp_query requests and merging the results, or by writing a manual query with $wpdb. I was just curious if you could do this with only the pre_get_posts hook.