Exclude post ID from wp_query

0
144

‘test-cat-1’, ‘order’ => ‘ASC’);
$q1 = new WP_query($args);
if($q1->have_posts()) :
$firstPosts = array();
while($q1->have_posts()) : $q1->the_post();
$firstPosts[] = $post->ID; // add post id to array
echo ‘

‘;
echo ”

” . get_the_title() . “

“;
echo ”

“;
endwhile;
endif;
/****************************************************************************/
// array of post id’s collected in first loop, can now be used as value for the ‘post__not_in’ parameter in second loops query $args
$args2 = array(‘post__not_in’ => $firstPosts, ‘order’ => ‘ASC’ );
$q2 = new WP_query($args2);
if($q2->have_posts()) :
while($q2->have_posts()) : $q2->the_post();
echo ‘

‘;
echo ”

” . get_the_title() . “

“;
echo ”

“;
endwhile;
endif;
?>