Insert additional code in between wordpress posts

Your code will be loaded before the second post.

Open index.php file.

1. add this code before “if have_posts()”:

<? php $postNo = 1; ?>

2. add this code after “while ( have_posts() ) : the_post(); ?>”:

<? php if ($postNo === 2) : ?>
/* put anything here*/
<? php endif; $postNo++; ?>

Full code preview:

<? php $poNo = 1; ?>
<? php if ( have_posts() ) : /* Start the Loop */ while ( have_posts() ) : the_post(); ?>

<? php if ($poNo === 2) : /* put any code here*/ endif; $poNo++; ?>
…..