How can I modify this code to iterate over an array of categories?

In short, yes!

$args = array(
    'post_type' => 'summerartcamp',
    'cat' => 15, //This is for the Morning Group - I'll have a second loop for the Afternoon Group
    'order' => 'ASC',
    'meta_key' => '_expiration-date',
    'orderby' => 'meta_value'
);

$the_query = new WP_Query( $args );

if ( $the_query->have_posts() /* Make sure you use the method, not the global function have_posts(), which only applies to the main loop */ ) {
    while ( $the_query->have_posts() ) {
        $the_query->the_post();

        foreach ( array( 16, 17, 18 ) as $the_cat_id ) {
            if ( in_category( $the_cat_id ) ) {
                $postsInCat = get_term_by( 'id', $the_cat_id, 'category' );

                if ( $postsInCat->count == 2 ) { // If the number of posts is two I only need to show the button for the second post
                    if (in_category( 22 ) ) {
                        echo 'This is the first post';
                        echo "<h2>" . get_the_title() . "</h2>";
                    }

                    if ( in_category( 23 ) ) {
                        echo 'This is the second post';
                    }

                } else if ( $postsInCat->count == 1 ) { // If there is only one post I'll give the full post
                    echo "<h2>" . get_the_title() . "</h2>";
                }
            }
        }
    }
}

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş