I have a grid where I display multiple posts types. I need to lay out the grid making sure that I have 2 posts from one post type, followed by 4 posts from another, flowing continously thereafter.

In addition, every post type needs to use a different class (for box size) on the grid.

Such as:

<!--- begin loop --->
<div class="big">
    1st post (must belong to post type 'movies')
</div>
<div class="big">
    2nd post (must belong to post type 'movies')
</div>
<div class="small">
    3rd post (must belong to post type 'artists')
</div>
<div class="small">
    4th post (must belong to post type 'artists')
</div>
<div class="small">
    5th post (must belong to post type 'artists')
</div>
<div class="small">
    6th post (must belong to post type 'artists')
</div>
<!--- end loop --->

This is what I have so far; I have managed to lay them out the way I want (visually), but I can’t find a way to make sure I have the right post type in the right position:

$counter  = 0;
// my custom query is called $latestposts       
foreach( $latestposts AS $grid ) {
$post = get_post( $grid->item_post_id );
setup_postdata( $post );
    if ($counter % 6 == 0 || $counter % 6 == 1){
        $grid_type = "big";
    } else {
       $grid_type = "small";
    }
    // including the template so I can have pagination
    include(locate_template('templates/loop-home.php'));
    $counter ++; 
}   

How can I make sure the big ones are post_type=movie and the small ones are post_type=artist?

Any help would be much appreciated. Thanks in advance.

Read more here: Multiple post types on a grid (every nth post must be a specific post type)


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , ,

Wordpress related questions and answers: