Can we count the WordPress loop and store it in a variable?
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php $post_id = get_the_ID(); ?>
<?php get_template_part('content','home'); ?>
some code to be executed
<?php endwhile; ?>
<?php endif; ?>
what I want is that for every 5 posts fetched ceratin code should be executed(example newsletter) → That means within the loop for every 5h, 10th, 15th, ____________ infinite posts(5n, n>=1) the code should be executed.