Break WordPress post loop and continue it

Break WordPress post loop and continue it

I have a WordPress blog that shows the last 10 posts on the main page:

< ?php if ( have_posts() ) : ?>

< ?php /* Start the Loop */ ?>
< ?php while ( have_posts() ) : the_post(); ?>

< ?php get_template_part( 'content', get_post_format() ); ?>

< ?php endwhile; ?>

I want to break the loop after 5 posts, put another code (a widget that I wrote), then … Read more