• Can I setup Adsense Deluxe to display ads on any post in the second and 5th Post position on every page without having to add code to every post individually. I would like it to attach itself to any post in the desired post position. Is there a way to embed it into the template code? Thanks

Viewing 1 replies (of 1 total)
  • Of course there is a way…

    Your theme has something like this in its index file:

    <?php while (have_posts()) : the_post(); ?>
      <div class="post">
        <!-- post-level stuff here -->
      </div>
    <?php endwhile; ?>

    In WordPress lingo, it’s called The Loop. What you need is to modify it along these lines:

    <?php $postsShownSoFar = 0; ?>
    <?php while (have_posts()) : the_post(); ?>
      <div class="post">
        <!-- post-level stuff here -->
        <?php 
    
          $postsShownSoFar = $postsShownSoFar + 1;
          if (($postsShownSoFar == 1) or ($postsShownSoFar == 5)) {
            // write ad display code here
          }
    
        ?>
      </div>
    <?php endwhile; ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Adsense Deluxe – apply to same post position on every page?’ is closed to new replies.