This is related to this other question, I tried with
WP_Query and basically every option I could find for 2 days now, no solution yet.
The full problem in hand: I have 2 post-types,
news. A post from "news" can be "featured" or "non-featured". I need to query 1 featured news, 4 articles and 2 non-featured news, and display them on a page in that order. The page uses the
The posts need to be in that specific order because the size of the post changes depending on the type and the "featured" meta option. My grid is using Masonry and the sequence that works to have a full grid (no holes or weird empty space) is
featured, article, article, article, article, non-featured, non-featured.
get_posts approach in the other question I can't get the pagination working. It works when navigating to
/page/X but I tried a bunch of custom pagination solutions that didn't work and
paginate_links which I couldn't get to work either.
So now I'm thinking of using a regular
WP_Query but how do I tell WordPress I want that many posts from each post-type and in that particular order?
Here's what I really want to do but I can't seem to find a way to do it with
WP_Query to make pagination work properly (damn pagination!):
$articles = get_posts(array( 'post_type' => 'articles', 'numberposts' => 4 )); $featured = get_posts(array( 'post_type' => 'news', 'numberposts' => 1, 'meta_query' => array( array( 'key' => 'featured-news', 'value' => 'Yes', 'compare' => 'LIKE' ) ) )); $non_featured = get_posts(array( 'post_type' => 'news', 'numberposts' => 2, 'meta_query' => array( array( 'key' => 'featured-news', 'value' => 'No', 'compare' => 'LIKE' ) ) )); // Merge in the order I need them to appear $all_posts = array_merge($featured, $articles, $non-featured); // The loop