Open beezee opened 12 years ago
This is done with a UNION query to return pk, type, and sort_by value. For example, to get users mixed with posts by date descending, query
( SELECT ID, 'user' AS TYPE , user_registered AS DATE FROM wp_users WHERE deleted = 0 ) UNION (
SELECT ID, 'post' AS TYPE , post_date AS DATE FROM wp_posts WHERE post_status = 'publish' ) ORDER BY DATE DESC LIMIT 0 , 20
to get the ids. group results by type (should match class) and perform model finder lookups on returned ids, order models together in results array and return.
This is only necessary for top level queries, related models are better suited for pagination in memory (depending on volume.)
When mixing different model types into one feed, pagination gets inconsistent. There should be an API that allows me to query for several types of models, and then mix them all together, maintaining consistent pagination in the process.