First x post with another template then the others

Question

I want to output the 5 latest posts. But the template of the first 2 must be different than the other 3 posts. So I’ve created two queries.

The first one shows the 2 posts:

<?php
$loop = new WP_Query( array(
   'post_type' => 'Post',
   'posts_per_page' => 2
   )
);
?>

 <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

      <?php get_template_part('loop-templates/blog-item-big'); ?>

 <?php endwhile; wp_reset_query(); ?>

The other query must show the other posts (limited with 3 posts):

<?php
$loop = new WP_Query( array(
   'post_type' => 'Post',
   'offset' => 2,
   'post_per_page' => 3
   )
);
?>

 <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

      <?php get_template_part('loop-templates/blog-item-small'); ?>

 <?php endwhile; wp_reset_query(); ?>

The first loop seems to work perfectly. It only shows the 2 last added posts. The second loop seems to start after the second post because of the offset parameter. But it shows more than 3 posts.

What is wrong with that query?

0
, , Dennis 1 year 2020-07-13T12:10:20-05:00 0 Answers 60 views 0

Leave an answer

Browse
Browse