Your query is structured a little weird.
$my_query = new WP_Query( array( 'posts_per_page' => 5 ) );
if ( $my_query->have_posts() ) {
while ( $my_query->have_posts() ) {
$the_query->the_post();
// Your desired template code
} // Close while()
// Restore original Post Data
wp_reset_postdata();
} // Close if()
This should be all you need to set it up since WP_Query
pages by default unless you override it by setting 'nopaging' => true
in your arguments for it.
Note that after the while()
loop ends, the statement wp_reset_postdata();
is used. This resets the original post data to the defaults.