You’re not showing your entire code, so not all of these suggestions may be relevant:
- Use distinct, ideally descriptive, names for the variables that hold the different queries. Using the same variable,
$my_query
, can lead to unintended consequences. - Be sure to close the first loop properly, with
endwhile; endif;
, before opening the second loop. - Be sure to call
wp_reset_postdata();
between the loops. - If your intent is merely to offset the second loop by the posts returned in the first loop, use the
offset
parameter, rather than explicitly excluding post IDs. - As @eric-holmes indicated,
showposts
is the wrong (and a deprecated) parameter to use, and should be replaced withposts_per_page
.
Example:
$query4posts = new WP_Query( array(
'cat' => 6,
'order' => 'ASC',
'posts_per_page' => 4
) );
$query8posts = new WP_Query( array(
'cat' => 6,
'order' => 'ASC',
'posts_per_page' => 8,
'offset' => 4
) );
// Output first loop of 4 posts
if ( $query4posts->have_posts() ) : while ( $query4posts->have_posts() ) : $query4posts->the_post();
// Loop output
endwhile; endif;
wp_reset_postdata();
// Output second loop of 8 posts, offset
if ( $query8posts->have_posts() ) : while ( $query8posts->have_posts() ) : $query8posts->the_post();
// Loop output
endwhile; endif;