A volte vi è la necessità di avere un post in evidenza seguito dagli altri della stessa categoria. Il problema è che non vogliamo che il primo post venga duplicato nel Loop successivo. Come fare?
La soluzione è la seguente:
$first_loop = new WP_Query( array(
'posts_per_page' => 1
));
$exclude_id = array();
while( $first_loop->have_posts() ):
$first_loop->the_post();
$id = get_the_ID();
$exclude_id[] = $id;
endwhile;
wp_reset_postdata();
$second_loop = new WP_Query( array(
'post__not_in' => $exclude_id,
'posts_per_page' => 6
));
while( $second_loop->have_posts() ):
$second_loop->the_post();
endwhile;
wp_reset_postdata();