My Computer Back in Service

“Make Your Computer Smile Again!”

Home ~ Blog ~ About Joe ~ About MCBS ~ Contact ~ Need Help?

If you're new here,  You may want to Subscribe to my RSS Feed or if you prefer ... Subscribe via e-mail. Thanks for visiting!

Do use AdSense on your Blog? Do you want to put some Ads after your posts but are limited by the fact that you can only have 3 instances of AdSense per page? Do you want to know how to show AdSense Ads after a certain post and not others to be sure you stay within Googles guidelines and not be banned?

Here’s how you can set up an AdSense campaign to show after one post per page. The example has the Ads showing after the second post, but you can set it up after any post number you like. And this also works on Category and “Next” pages without any other changes being made to your code.

Go to your index.php in the Presentation folder of your WordPress Dashboard.

And look for:

<?php if (have_posts()) :?>
  <?php $postCount=0; ?>
  <?php while (have_posts()) : the_post();?>

And IMMEDIATELY BEFORE it put this bit of code:

<?php
$postnum = 1;
$showadsense1 = 2;
?>

Go a little further down in the code and look for this (at the end of the content statement)

<?php endwhile; ?>

And place this bit of code RIGHT BEFORE that statement:

<?php
 if ($postnum == $showadsense1)
  (your AdSense code  goes here)
$postnum++;
?>

It’s as simple as that. There should be no need to make any changes if and when you update your WordPress version, but you will have to remember to redo the code if you change your Theme.

You should be able to copy/paste the above code with no problems, just remember to put YOUR AdSense code in place of “(your AdSense code goes here)” or it will never work.

Questions or problems can be left in comments and I will answer them there so others will know the answer to your question too.

Related Posts:
  • How to Insert Titles Instead of Previous/Next Links
  • When your readers stop by on an individual post you probably would like...
  • Offer Your Readers The Option to Print Your Posts
  • How many times have you read an article on one of your favorite Blogs and s...
  • The Unofficial Pre-launch Post!
  •  Thanks for stopping by. Even though the Official Launch of My Computer...

    Need Help?


    Recommended by Joe

    Leave a Reply

    `