WordPress: multiple loops I have two loops on my page - each with their own category. It works, but I don't know if this is the best practice as I'm pretty new to this stuff.

&lt;?php $my_query = new WP_Query( 'category_name=news&amp;posts_per_page=3' );
        while ( $my_query-&gt;have_posts() ) : $my_query-&gt;the_post();
                $do_not_duplicate[] = $post-&gt;ID; ?&gt;
                &lt;!-- Do stuff... --&gt;
&lt;?php get_template_part( 'content', get_post_format() ); ?&gt;

&lt;?php endwhile; ?&gt;

&lt;?php $second_query = new WP_Query( 'category_name=reviews&amp;posts_per_page=4' );
        while ( $second_query-&gt;have_posts() ) : $second_query-&gt;the_post();
                $do_not_duplicate[] = $post-&gt;ID; ?&gt;
                &lt;!-- Do stuff... --&gt;
&lt;?php get_template_part( 'content', get_post_format() ); ?&gt;

&lt;?php endwhile; ?&gt;
The only thing that changes between the first and second half is the query parameters.

&lt;?php

foreach (array('news' =&gt; 3, 'reviews' =&gt; 4) as $category =&gt; $posts_per_page) {
    $wp_query = new WP_Query(
        "category_name=$category&amp;posts_per_page=$posts_per_page"
    );
    while ( $wp_query-&gt;have_posts() ) {
        # etc.
    }
}

?&gt;