title: Adsense ads between a grid loop of posts in WordPress?
body: <p>I'm having some issues trying to insert Google Adsense codes between posts. First, have a look at the image below:</p>
  
  <p><img src="https://i.stack.imgur.com/Wu175.png" alt="enter image description here"></p>
  
  <p>I have a grid of 12 posts on my homepage, each row containing 3 posts.</p>
  
  <p>How could I put an Adsense ad on the second post of the first row, then another ad code as the same size of the full length of the container after the second row os posts, and then another ad at the 11th post.</p>
  
  <p>I know it's possible but i'm really struggling with it.</p>
  
  <h3><code>index.php</code> loop:</h3>
  
  <pre><code>&lt;?php if ( have_posts() ) : ?&gt;
  
          &lt;?php /* Start the Loop */ ?&gt;
  
          &lt;?php while ( have_posts() ) : the_post(); ?&gt;
  
              &lt;?php get_template_part( 'content', get_post_format() ); ?&gt;
  
          &lt;?php endwhile; ?&gt;
  
          &lt;?php hct_content_nav( 'nav-below' ); ?&gt;
  
      &lt;?php else : ?&gt;
  
          &lt;article id="post-0" class="post no-results not-found"&gt;
              &lt;header class="entry-header"&gt;
                  &lt;h1 class="entry-title"&gt;&lt;?php _e( 'Nothing Found', 'hct' ); ?&gt;&lt;/h1&gt;
              &lt;/header&gt;&lt;!-- .entry-header --&gt;
  
              &lt;div class="entry-content"&gt;
                  &lt;p&gt;&lt;?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'hct' ); ?&gt;&lt;/p&gt;
                  &lt;?php get_search_form(); ?&gt;
              &lt;/div&gt;&lt;!-- .entry-content --&gt;
          &lt;/article&gt;&lt;!-- #post-0 --&gt;
  
      &lt;?php endif; ?&gt;
  
      &lt;/div&gt;&lt;!-- #content --&gt;
  </code></pre>
  
  <h3>And the <code>content.php</code> code, which is called by <code>index.php</code>:</h3>
  
  <pre><code>&lt;?php $count = $wp_query-&gt;current_post;
       $c     = fmod($count,3);
       if ($c == '2') : ?&gt;
  &lt;div style="clear:both;"&gt;&lt;/div&gt;
  </code></pre>